Commit 8047b9cc by source_reader

cleanup for home directories

parent 616e98bb
......@@ -5,6 +5,7 @@ After = syslog.target postgresql.service
[Service]
Type = oneshot
Environment="HOME=/root"
ExecStart = /usr/local/bin/first_boot
StandardOutput = journal
StandardError = journal
......
......@@ -29,6 +29,47 @@ deb http://archive.raspberrypi.org/debian/ stretch main ui
EOF
apt update
echo "6] Configuring root fs resize for first boot"
PARTUUID="$(blkid -o export /dev/mmcblk0p2 | grep PARTUUID)"
cat > /boot/cmdline.txt <<EOF
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=025ce4e3-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=$PARTUUID rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles
EOF
cat > /etc/init.d/resize2fs_once << 'EOF'
#!/bin/sh
#!/bin/sh
### BEGIN INIT INFO
# Provides: resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 3
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
### END INIT INFO
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting resize2fs_once"
ROOT_DEV=$(findmnt / -o source -n) &&
resize2fs $ROOT_DEV &&
update-rc.d resize2fs_once remove &&
rm /etc/init.d/resize2fs_once &&
log_end_msg $?
;;
*)
echo "Usage: $0 start" >&2
exit 3
;;
esac
EOF
chmod +x /etc/init.d/resize2fs_once
systemctl enable resize2fs_once
echo "7] Cleanup home directory"
cd /home/pi
ls -A | grep ^'\.' | grep -Ev ".bashrc|.bash_logout|.local|.profile" | xargs rm -rf
cd /root
ls -A | grep ^'\.' | grep -Ev ".bashrc|.profile|.vnc" | xargs rm -rf
echo "ALL DONE! Remember to remove the puppet directory!!"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment