Option to prepare with hostkeys left untouched
This commit is contained in:
parent
ee4e7ac5c8
commit
9613c75afd
17
pishrink.sh
17
pishrink.sh
|
@ -155,7 +155,7 @@ EOF1
|
||||||
help() {
|
help() {
|
||||||
local help
|
local help
|
||||||
read -r -d '' help << EOM
|
read -r -d '' help << EOM
|
||||||
Usage: $0 [-adhrspvzZ] imagefile.img [newimagefile.img]
|
Usage: $0 [-adhrspPvzZ] imagefile.img [newimagefile.img]
|
||||||
|
|
||||||
-s Don't expand filesystem when image is booted the first time
|
-s Don't expand filesystem when image is booted the first time
|
||||||
-v Be verbose
|
-v Be verbose
|
||||||
|
@ -163,7 +163,8 @@ Usage: $0 [-adhrspvzZ] imagefile.img [newimagefile.img]
|
||||||
-z Compress image after shrinking with gzip
|
-z Compress image after shrinking with gzip
|
||||||
-Z Compress image after shrinking with xz
|
-Z Compress image after shrinking with xz
|
||||||
-a Compress image in parallel using multiple cores
|
-a Compress image in parallel using multiple cores
|
||||||
-p Remove logs, apt archives, dhcp leases and ssh hostkeys
|
-p Remove logs, apt archives, dhcp leases
|
||||||
|
-P Remove logs, apt archives, dhcp leases and ssh hostkeys
|
||||||
-d Write debug messages in a debug log file
|
-d Write debug messages in a debug log file
|
||||||
EOM
|
EOM
|
||||||
echo "$help"
|
echo "$help"
|
||||||
|
@ -176,14 +177,16 @@ repair=false
|
||||||
parallel=false
|
parallel=false
|
||||||
verbose=false
|
verbose=false
|
||||||
prep=false
|
prep=false
|
||||||
|
prep_hostkeys=false
|
||||||
ziptool=""
|
ziptool=""
|
||||||
|
|
||||||
while getopts ":adhprsvzZ" opt; do
|
while getopts ":adhpPrsvzZ" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
a) parallel=true;;
|
a) parallel=true;;
|
||||||
d) debug=true;;
|
d) debug=true;;
|
||||||
h) help;;
|
h) help;;
|
||||||
p) prep=true;;
|
p) prep=true;;
|
||||||
|
P) prep=true; prep_hostkeys=true;;
|
||||||
r) repair=true;;
|
r) repair=true;;
|
||||||
s) should_skip_autoexpand=true ;;
|
s) should_skip_autoexpand=true ;;
|
||||||
v) verbose=true;;
|
v) verbose=true;;
|
||||||
|
@ -305,10 +308,14 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $prep == true ]]; then
|
if [[ $prep == true ]]; then
|
||||||
info "Syspreping: Removing logs, apt archives, dhcp leases and ssh hostkeys"
|
info "Syspreping: Removing logs, apt archives and dhcp leases"
|
||||||
mountdir=$(mktemp -d)
|
mountdir=$(mktemp -d)
|
||||||
mount "$loopback" "$mountdir"
|
mount "$loopback" "$mountdir"
|
||||||
rm -rvf $mountdir/var/cache/apt/archives/* $mountdir/var/lib/dhcpcd5/* $mountdir/var/log/* $mountdir/var/tmp/* $mountdir/tmp/* $mountdir/etc/ssh/*_host_*
|
rm -rvf $mountdir/var/cache/apt/archives/* $mountdir/var/lib/dhcpcd5/* $mountdir/var/log/* $mountdir/var/tmp/* $mountdir/tmp/*
|
||||||
|
if [[ "$prep_hostkeys" == true ]]; then
|
||||||
|
info "Syspreping: Removing ssh hostkeys"
|
||||||
|
rm -rvf $mountdir/etc/ssh/*_host_*
|
||||||
|
fi
|
||||||
umount "$mountdir"
|
umount "$mountdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue