50 lines
1.0 KiB
Plaintext
50 lines
1.0 KiB
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
#@@@@#
|
||
|
|
||
|
LOGFILE="/home/sats/satsd/log/install.log";
|
||
|
|
||
|
|
||
|
plog(){
|
||
|
sudo -u sats tee -a /home/sats/satsd/log/install.log > /dev/null;
|
||
|
}
|
||
|
|
||
|
slog(){
|
||
|
echo "$1" | plog;
|
||
|
}
|
||
|
|
||
|
failexit(){
|
||
|
slog " > failed";
|
||
|
exit 127;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
# [1] Notify boot (first or normal) #
|
||
|
echo;
|
||
|
test ! -e /target/sync && echo "First Boot" | plog;
|
||
|
test -e /target/sync && echo "Normal Boot" | plog;
|
||
|
slog "============";
|
||
|
|
||
|
|
||
|
# [2] Start ssh service
|
||
|
slog " * 1. Starting ssh service";
|
||
|
sudo systemctl start ssh \
|
||
|
&& slog " > done" \
|
||
|
|| failexit;
|
||
|
|
||
|
# [3] Set random passwords for 'sats'
|
||
|
echo " * 2. Changing sats password" | plog;
|
||
|
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
|
||
|
echo -ne "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd sats;
|
||
|
test $? -eq 0 \
|
||
|
&& slog " > done" \
|
||
|
|| failexit;
|
||
|
|
||
|
# [4] Set random passwords for 'pi' itself
|
||
|
echo " * 3. Changing pi password" | plog;
|
||
|
RANDOM_PASS=$(tr -cd A-Za-z0-9_ < /dev/urandom | head -c 256);
|
||
|
echo -ne "$RANDOM_PASS\n$RANDOM_PASS\n" | sudo passwd pi;
|
||
|
test $? -eq 0 \
|
||
|
&& slog " > done" \
|
||
|
|| failexit;
|