|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # shellcheck disable=SC2064 |
3 | 3 |
|
| 4 | +base_dir="$(dirname "$(readlink -m "$0")")" |
| 5 | + |
4 | 6 | check_exists() |
5 | 7 | { |
6 | 8 | command -v "$1" > /dev/null |
@@ -91,7 +93,7 @@ run_main() |
91 | 93 | exit 1 |
92 | 94 | fi |
93 | 95 |
|
94 | | - if [[ ! -x "$(dirname "$0")/rpcauth.py" ]]; then |
| 96 | + if [[ ! -x "$base_dir/rpcauth.py" ]]; then |
95 | 97 | echo "Error: rpcauth.py not found or is not executable." |
96 | 98 | exit 1 |
97 | 99 | fi |
@@ -231,7 +233,7 @@ run_main() |
231 | 233 | # generate a bitcoin RPC auth |
232 | 234 | echo -n "Generating bitcoin RPC auth ... " |
233 | 235 | bitcoind_rpcuser="rpc" |
234 | | - rpcauth_out="$(python3 "$(dirname "$0")/rpcauth.py" $bitcoind_rpcuser)" |
| 236 | + rpcauth_out="$(python3 "$base_dir/rpcauth.py" $bitcoind_rpcuser)" |
235 | 237 | if [[ -z $rpcauth_out ]]; then |
236 | 238 | echo "" |
237 | 239 | echo "Error: failed to generate bitcoin RPC auth." |
@@ -287,11 +289,21 @@ run_main() |
287 | 289 | if [[ "$update_update" -eq 1 ]]; then |
288 | 290 | # update /sysupdates/update.sh on SSD from local copy |
289 | 291 | echo -n "Updating /sysupdates/update.sh on SSD ... " |
290 | | - cp "$(dirname "$0")/update.sh" "$SSD_MOUNT_POINT"/sysupdates/update.sh |
| 292 | + cp "$base_dir/update.sh" "$SSD_MOUNT_POINT"/sysupdates/update.sh |
291 | 293 | chmod +x "$SSD_MOUNT_POINT"/sysupdates/update.sh |
292 | 294 | echo "done." |
293 | 295 | fi |
294 | 296 |
|
| 297 | + # clear logs, shell history, ssh keys and networks |
| 298 | + echo -n "Clearing logs, shell history, ssh keys and networks ... " |
| 299 | + rm -f "$USD_MOUNT_POINT"/var/log/* 2> /dev/null |
| 300 | + for d in "$USD_MOUNT_POINT"/var/log/socklog/*; do echo > "$d/current"; done |
| 301 | + rm -f "$USD_MOUNT_POINT"/root/.bash_history |
| 302 | + mkdir -p "$USD_MOUNT_POINT"/root/.ssh |
| 303 | + echo > "$USD_MOUNT_POINT"/root/.ssh/authorized_keys |
| 304 | + cp "$base_dir"/../rootfiles/etc/wpa_supplicant/wpa_supplicant.conf "$USD_MOUNT_POINT"/etc/wpa_supplicant/wpa_supplicant.conf |
| 305 | + echo "done." |
| 306 | + |
295 | 307 | sync |
296 | 308 | echo "All DONE, Nakamochi uSD and SSD should be ready!" |
297 | 309 | } |
|
0 commit comments