2024-02-14 10:37:43 -08:00
|
|
|
#!/bin/vbash
|
|
|
|
|
|
|
|
if [ "$(id -g -n)" != 'vyattacfg' ] ; then
|
|
|
|
exec sg vyattacfg -c "/bin/vbash $(readlink -f $0) $@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
source /opt/vyatta/etc/functions/script-template
|
2024-02-14 11:19:29 -08:00
|
|
|
source vyos_secrets.env
|
2024-02-14 10:37:43 -08:00
|
|
|
|
2024-02-14 10:47:46 -08:00
|
|
|
configure
|
|
|
|
|
2024-02-14 11:07:57 -08:00
|
|
|
echo "===== Configure firewall... ====="
|
|
|
|
{
|
2024-02-14 11:19:29 -08:00
|
|
|
source firewall.sh > /dev/null
|
2024-02-14 11:07:57 -08:00
|
|
|
} || {
|
|
|
|
echo "===== Failed to configure firewall ====="
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "===== Configure interfaces... ====="
|
|
|
|
{
|
2024-02-14 11:19:29 -08:00
|
|
|
source interfaces.sh > /dev/null
|
2024-02-14 11:07:57 -08:00
|
|
|
} || {
|
|
|
|
echo "===== Failed to configure interfaces ====="
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "===== Configure NAT... ====="
|
|
|
|
{
|
2024-02-14 11:19:29 -08:00
|
|
|
source nat.sh > /dev/null
|
2024-02-14 11:07:57 -08:00
|
|
|
} || {
|
|
|
|
echo "===== Failed to configure NAT ====="
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "===== Configure QoS... ====="
|
|
|
|
{
|
2024-02-14 11:19:29 -08:00
|
|
|
source qos.sh > /dev/null
|
2024-02-14 11:07:57 -08:00
|
|
|
} || {
|
|
|
|
echo "===== Failed to configure QoS ====="
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo "===== Configure services... ====="
|
|
|
|
{
|
2024-02-14 11:19:29 -08:00
|
|
|
source service.sh > /dev/null
|
2024-02-14 11:07:57 -08:00
|
|
|
} || {
|
|
|
|
echo "===== Failed to configure services ====="
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo "===== Configure system... ====="
|
|
|
|
{
|
2024-02-14 11:19:29 -08:00
|
|
|
source system.sh > /dev/null
|
2024-02-14 11:07:57 -08:00
|
|
|
} || {
|
|
|
|
echo "===== Failed to configure system ====="
|
|
|
|
}
|
|
|
|
|
2024-02-14 12:35:16 -08:00
|
|
|
if compare | grep -q 'No changes between working and active configurations.'
|
2024-02-14 12:25:48 -08:00
|
|
|
then
|
2024-02-14 12:35:16 -08:00
|
|
|
echo "No changes to commit."
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
{ # compare, try commit, save, exit
|
2024-02-14 12:47:23 -08:00
|
|
|
compare | strip-private
|
2024-02-14 12:25:48 -08:00
|
|
|
commit && save && exit
|
|
|
|
} || { # catch, exit discard and print a very basic error message
|
|
|
|
exit discard
|
|
|
|
echo "Failed to commit and save the configuration."
|
|
|
|
}
|
|
|
|
fi
|