ungleich-tools/openwrt/viirb-4-cleanup.sh

42 lines
854 B
Bash
Raw Normal View History

#!/bin/sh
# Nico Schottelius
# 2020-06-14
set -e
set -x
2020-06-14 20:54:40 +00:00
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
2020-06-14 20:54:40 +00:00
id=$1; shift
viirb_hostname=viirb${id}
root_password=$(pwgen -1 32)
2020-06-14 20:54:40 +00:00
# Save for sending to user
# FIXME: future make this more easy / better to transfer
echo $root_password > ${viirb_hostname}.rootpw
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
EOF
2020-06-14 20:54:40 +00:00
echo "Submit to user the root password = ${root_password}"