You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
4.1 KiB
Bash
70 lines
4.1 KiB
Bash
12 months ago
|
#!/usr/bin/env bash
|
||
|
# Stage 3 booster to prepare router for first real boot
|
||
|
|
||
|
# Log to the system log and echo if needed
|
||
|
log_say()
|
||
|
{
|
||
|
SCRIPT_NAME=$(basename "$0")
|
||
|
echo "${SCRIPT_NAME}: ${1}"
|
||
|
logger "${SCRIPT_NAME}: ${1}"
|
||
|
}
|
||
|
|
||
|
log_say " "
|
||
|
log_say " ███████████ ███ █████ "
|
||
|
log_say "░░███░░░░░███ ░░░ ░░███ "
|
||
|
log_say " ░███ ░███ ████████ ████ █████ █████ ██████ ███████ ██████ "
|
||
|
log_say " ░██████████ ░░███░░███░░███ ░░███ ░░███ ░░░░░███ ░░░███░ ███░░███"
|
||
|
log_say " ░███░░░░░░ ░███ ░░░ ░███ ░███ ░███ ███████ ░███ ░███████ "
|
||
|
log_say " ░███ ░███ ░███ ░░███ ███ ███░░███ ░███ ███░███░░░ "
|
||
|
log_say " █████ █████ █████ ░░█████ ░░████████ ░░█████ ░░██████ "
|
||
|
log_say "░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ "
|
||
|
log_say " "
|
||
|
log_say " "
|
||
|
log_say " ███████████ █████ "
|
||
|
log_say "░░███░░░░░███ ░░███ "
|
||
|
log_say " ░███ ░███ ██████ █████ ████ ███████ ██████ ████████ "
|
||
|
log_say " ░██████████ ███░░███░░███ ░███ ░░░███░ ███░░███░░███░░███ "
|
||
|
log_say " ░███░░░░░███ ░███ ░███ ░███ ░███ ░███ ░███████ ░███ ░░░ "
|
||
|
log_say " ░███ ░███ ░███ ░███ ░███ ░███ ░███ ███░███░░░ ░███ "
|
||
|
log_say " █████ █████░░██████ ░░████████ ░░█████ ░░██████ █████ "
|
||
|
log_say "░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░ "
|
||
|
|
||
|
# Command to wait for Internet connection
|
||
|
wait_for_internet() {
|
||
|
while ! ping -q -c3 1.1.1.1 >/dev/null 2>&1; do
|
||
|
log_say "Waiting for Internet connection..."
|
||
|
sleep 1
|
||
|
done
|
||
|
log_say "Internet connection established"
|
||
|
}
|
||
|
|
||
|
# Wait for Internet connection
|
||
|
wait_for_internet
|
||
|
|
||
|
# Command to wait for opkg to finish
|
||
|
wait_for_opkg() {
|
||
|
while pgrep -x opkg >/dev/null; do
|
||
|
log_say "Waiting for opkg to finish..."
|
||
|
sleep 1
|
||
|
done
|
||
|
log_say "opkg is released, our turn!"
|
||
|
}
|
||
|
|
||
|
# Wait for opkg to finish
|
||
|
wait_for_opkg
|
||
|
|
||
|
# Cleanup our auto-provision and prepare for first real boot
|
||
|
[ -d /etc/auto-provision ] && rm -rf /etc/auto-provision
|
||
|
[ -f /etc/rc.local ] && echo "# Empty by design" > /etc/rc.local
|
||
|
|
||
|
# Download our startup.tar.gz with our startup scripts and load them in
|
||
|
log_say "Downloading startup.tar.gz"
|
||
|
wget -q -O /tmp/startup.tar.gz https://github.com/PrivateRouter-LLC/script-repo/raw/main/startup-scripts/startup.tar.gz
|
||
|
log_say "Extracting startup.tar.gz"
|
||
|
tar -xzf /tmp/startup.tar.gz -C /etc
|
||
|
|
||
|
log_say "Removing our script before reboot"
|
||
|
rm -- "$0"
|
||
|
|
||
|
log_say "Reboot to uptake our rc.custom boot script"
|
||
|
reboot
|