Last active
November 21, 2018 21:32
-
-
Save jzila/57a973ff97cdb143963ba0bdc061e810 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# | |
# rc.local | |
# | |
# This script is executed at the end of each multiuser runlevel. | |
# Make sure that the script will "exit 0" on success or any other | |
# value on error. | |
# | |
# In order to enable or disable this script just change the execution | |
# bits. | |
# | |
# By default this script does nothing. | |
pendingTime=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.pendingTime'); | |
existingPendingTime=$(cat /etc/pendingTime 2>/dev/null || echo -n ''); | |
echo "pendingTime=$pendingTime" | |
echo "existingPendingTime=$existingPendingTime" | |
if [ "$pendingTime" != "$existingPendingTime" ]; then | |
echo -n "$pendingTime" > /etc/pendingTime; | |
# Force make an ext4 filesystem, but only one force option (will fail if it's mounted). | |
mke2fs -F -q -t ext4 /dev/nvme0n1; | |
# Reset the fstab to correctly specify the mount drive, then mount it. | |
echo "LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0" > /etc/fstab; | |
echo "/dev/nvme0n1 /var/lib/jenkins ext4 auto,relatime,nofail 0 0" >> /etc/fstab; | |
mount /dev/nvme0n1; | |
# Remove the default lost+found. | |
rm -rf /var/lib/jenkins/lost+found 2>/dev/null || echo "Nothing to remove"; | |
# Set the permissions for the new mount. | |
chown jenkins:jenkins /var/lib/jenkins; | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment