#!/bin/bash
#####################################################################
############## Configuration Backup and Restore Script #############
#####################################################################
# List of configuration files to backup and restore
config_files=(
"autossh"
"dhcp"
"firewall"
"fstab"
"pineap"
"network"
"system"
"wireless"
)
# Backup directory
backup_dir="/etc/config/backup"
# Function to backup configuration files
backup_config() {
if [ ! -d "$backup_dir" ]; then
mkdir "$backup_dir"
fi
for file in "${config_files[@]}"; do
backup_file="$backup_dir/$file.backup"
if [ -f "/etc/config/$file" ]; then
if [ ! -f "$backup_file" ]; then
cp "/etc/config/$file" "$backup_file"
echo "Created backup for $file configuration at $backup_file"
else
echo "Backup for $file configuration already exists at $backup_file"
fi
else
echo "Warning: /etc/config/$file does not exist, skipping backup."
fi
done
}
# Function to restore configuration files
restore_config() {
for file in "${config_files[@]}"; do
backup_file="$backup_dir/$file.backup"
if [ -f "$backup_file" ]; then
cp "$backup_file" "/etc/config/$file"
echo "Restored $file configuration from $backup_file"
else
echo "Warning: $backup_file does not exist, skipping restore."
fi
done
}
# Function to run the LED color sequence
run_led_sequence() {
# Color sequence
colors=("G" "Y" "G" "Y" "G" "Y" "G" "B")
# Duration for each color (in seconds)
duration=0.1
for color in "${colors[@]}"; do
LED $color VERYFAST
sleep $duration
LED $color SOLID
sleep $duration
done
LED B SUCCESS
}
# Main script execution
backup_config
restore_config
run_led_sequence
Button script to backup all settings to a subfolder /backup and then do some randomized diod blinking.
Backup is done if there are no backup files, otherwise it creates the files and flashes. usefull if you get locked outof root portal after playing with iptables instead of flashing recovery.