Skip to content

Commit 9887be7

Browse files
committed
installer: add cleanup options
1 parent 6622528 commit 9887be7

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

doc/INSTALL_CUSTOM.md

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@
112112
| Parameter | Default | Options | Description |
113113
|--------------------------------|------------------------------------------------------------------------------------------------|--------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
114114
| `quiet_boot` | `0` | `0`/`1` | Disables most log messages on boot. |
115+
| `cleanup` | `0` | `0`/`1` | Remove installer files after success. To also remove log files, note the option below. |
116+
| `cleanup_logfiles` | `0` | `0`/`1` | Removes installer log files after success. |
115117
| `cmdline` | `"dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 elevator=deadline fsck.repair=yes"` | | |
116118
| `rootfs_install_mount_options` | | | |
117119
| `rootfs_mount_options` | | | |

scripts/opt/raspberrypi-ua-netinst/install.sh

+21-7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ final_action=reboot
5959
hwrng_support=1
6060
enable_watchdog=0
6161
quiet_boot=0
62+
cleanup=0
63+
cleanup_logfiles=0
6264
spi_enable=0
6365
i2c_enable=0
6466
i2c_baudrate=
@@ -83,7 +85,7 @@ fail()
8385
mount "${bootpartition}" /boot
8486
fail_boot_mounted=true
8587
fi
86-
cp -- ${LOGFILE} /boot/raspberrypi-ua-netinst/error-"$(date +%Y%m%dT%H%M%S)".log
88+
cp "${LOGFILE}" "/boot/raspberrypi-ua-netinst/error-$(date +%Y%m%dT%H%M%S).log"
8789
sync
8890

8991
# if we mounted /boot in the fail command, unmount it.
@@ -350,7 +352,7 @@ echo "OK"
350352

351353
# copy boot data to safety
352354
echo -n "Copying boot files... "
353-
cp -r -- /boot/* /bootfs/ || fail
355+
cp -r /boot/* /bootfs/ || fail
354356
echo "OK"
355357

356358
# Read installer-config.txt
@@ -876,6 +878,8 @@ echo " rootfs_install_mount_options = ${rootfs_install_mount_options}"
876878
echo " rootfs_mount_options = ${rootfs_mount_options}"
877879
echo " final_action = ${final_action}"
878880
echo " quiet_boot = ${quiet_boot}"
881+
echo " cleanup = ${cleanup}"
882+
echo " cleanup_logfiles = ${cleanup_logfiles}"
879883
echo " spi_enable = ${spi_enable}"
880884
echo " i2c_enable = ${i2c_enable}"
881885
echo " i2c_baudrate = ${i2c_baudrate}"
@@ -1034,7 +1038,7 @@ echo "OK"
10341038

10351039
echo -n "Copying /boot files in... "
10361040
mount "${bootpartition}" /boot || fail
1037-
cp -r -- /bootfs/* /boot || fail
1041+
cp -r /bootfs/* /boot || fail
10381042
sync
10391043
umount /boot || fail
10401044
echo "OK"
@@ -1763,12 +1767,22 @@ echo -n "Installation finished at $(date --date="@${ENDTIME}" --utc)"
17631767
echo " and took $((DURATION/60)) min $((DURATION%60)) sec (${DURATION} seconds)"
17641768

17651769
# copy logfile to standard log directory
1766-
sleep 1
1767-
cp -- "${LOGFILE}" /rootfs/var/log/raspberrypi-ua-netinst.log
1768-
chmod 0640 /rootfs/var/log/raspberrypi-ua-netinst.log
1770+
if [ "${cleanup_logfiles}" = "1" ]; then
1771+
rm -f /rootfs/boot/raspberrypi-ua-netinst/error-*.log
1772+
else
1773+
sleep 1
1774+
cp "${LOGFILE}" /rootfs/var/log/raspberrypi-ua-netinst.log
1775+
chmod 0640 /rootfs/var/log/raspberrypi-ua-netinst.log
1776+
fi
17691777

1770-
echo -n "Unmounting filesystems... "
1778+
# Cleanup installer files
1779+
if [ "${cleanup}" = "1" ]; then
1780+
echo -n "Removing installer files... "
1781+
rm -rf /rootfs/boot/raspberrypi-ua-netinst/
1782+
echo "OK"
1783+
fi
17711784

1785+
echo -n "Unmounting filesystems... "
17721786
umount /rootfs/boot
17731787
umount /rootfs
17741788
echo "OK"

0 commit comments

Comments
 (0)