ungleich-tools/openwrt/viirb-4-cleanup.sh
2021-08-13 12:22:15 +02:00

43 lines
849 B
Bash
Executable file

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