61 lines
2.0 KiB
Bash
Executable File
61 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
########################################################################
|
|
# Copyright (C) 2015 Max Mehl <mail@mehl.mx>
|
|
########################################################################
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
########################################################################
|
|
#
|
|
# With this script you can update a index page, e.g. after an update
|
|
#
|
|
########################################################################
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$0")")"
|
|
# Test if config.cfg exists and set needed variables
|
|
if [ ! -e config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi
|
|
source config.cfg
|
|
|
|
number="98"
|
|
while [ $number != "99" ]
|
|
do
|
|
if [ "$1" == "" ]; then
|
|
for ((i = 0; i < ${#NAME[*]}; i++)); do
|
|
echo "$i. ${NAME[$i]} ${HOST[$i]}"
|
|
done
|
|
|
|
echo "99. Cancel."
|
|
read -p "Which host's original index site should be updated? " number
|
|
|
|
else
|
|
number="$1"
|
|
fi
|
|
|
|
if [ "$number" == 99 ]; then
|
|
echo "Update canceled."
|
|
exit 1
|
|
fi
|
|
|
|
CURNAME=${NAME[$number]}
|
|
CURHOST=${HOST[$number]}
|
|
|
|
if [ -e sites/"$CURHOST".orig ]; then
|
|
rm sites/"$CURHOST".orig
|
|
fi
|
|
wget -q -T 5 -t 2 -U $(cat monitor-user-agent.txt) -O sites/"$CURHOST".orig http://"$CURHOST"
|
|
echo "[INFO] Successfully updated $CURNAME ($CURHOST). Enter another host to update or cancel with 99."
|
|
echo
|
|
done
|