Firstrun and resize script rework. Jessie and Trusty don't need reboot to expand file system, only Wheezy.

This commit is contained in:
Igor Pečovnik
2016-01-13 12:10:21 +01:00
parent 2f3eff30ec
commit 90fb1bb23b
4 changed files with 281 additions and 112 deletions

View File

@@ -29,28 +29,13 @@ rootfstype=$(blkid -s TYPE -o value $root_partition)
case "$1" in
start)
if [[ $rootfstype == ext4 && ! -f "/root/.no_rootfs_resize" ]]; then
echo -e "[\e[0;32m ok \x1B[0m] Resizing SD card file-system"
/sbin/resize2fs $device >/dev/null 2>&1
fi
echo -e "[\e[0;32m ok \x1B[0m] Force password change upon first login"
chage -d 0 root
echo -e "[\e[0;32m ok \x1B[0m] Creating 128Mb emergency swap area"
dd if=/dev/zero of=/var/swap bs=1024 count=131072 status=noxfer >/dev/null 2>&1
chown root:root /var/swap
chmod 0600 /var/swap
mkswap /var/swap >/dev/null 2>&1
swapon /var/swap >/dev/null 2>&1
echo "/var/swap none swap sw 0 0" >> /etc/fstab
echo 'vm.swappiness=0' >> /etc/sysctl.conf
update-rc.d -f resize2fs remove >/dev/null 2>&1
;;
stop)
echo -e "[\e[0;32m ok \x1B[0m] Resizing in next start"
;;
*)
echo "Usage: $N {start}" >&2
exit 1
;;
*)
exit 1
;;
esac
exit 0