ungleich-tools/openwrt/vigir-4-cleanup.sh
2021-11-16 14:17:22 +01:00

43 lines
854 B
Bash
Executable file

#!/bin/sh
# Nico Schottelius
# 2020-12-21
set -e
set -x
if [ $# -ne 2 ]; then
echo "$0 vigir-ip-address vigir-id"
echo " vigir-ip-address: where to find the vigir"
echo " vigir-id: number in decimal format"
exit 1
fi
vigir_ip=$1; shift
id=$1; shift
vigir_hostname=vigir${id}
root_password=$(pwgen -1 32)
cat <<EOF | ssh -t "root@${vigir_ip}"
# Remove temporary IP
# Correct test SSID to final one
uci set wireless.default_radio0.ssid='IPv6 everywhere'
uci set wireless.default_radio1.ssid='IPv6 everywhere 5Ghz'
uci commit
# Remove our ssh keys
rm -f /etc/dropbear/authorized_keys
# Setup root password
printf "${root_password}\n${root_password}\n" | passwd
reboot
EOF
printf "${root_password}\n${root_password}\n" | pass insert vigir/vigir${id}
pass git push
echo "Submit to user the root password = ${root_password}"