2022-06-03 21:48:41 +02:00
|
|
|
#! /bin/bash -
|
|
|
|
# Implementing update functionality for an PSA.
|
2022-06-03 20:42:26 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
2022-06-03 21:48:41 +02:00
|
|
|
# UPDATE PSA
|
|
|
|
# Usage:
|
|
|
|
# update_psa [ --? ]
|
2023-05-24 16:47:54 +02:00
|
|
|
# [ -m ]
|
2022-06-03 21:48:41 +02:00
|
|
|
# [ --help ]
|
|
|
|
# [ --wdir "working_directory" ]
|
|
|
|
# [ --file "config_file" ]
|
|
|
|
# [ --dbg ]
|
|
|
|
# [ --version ]
|
2022-06-03 20:42:26 +02:00
|
|
|
#
|
2022-06-03 21:48:41 +02:00
|
|
|
# ./update_psa --file $PWD/update_psa.conf --wdir $PWD
|
|
|
|
#
|
2022-06-03 20:42:26 +02:00
|
|
|
###############################################################################
|
2023-03-30 14:56:49 +02:00
|
|
|
# if [ $# -eq 0 ]; then
|
2022-06-03 21:48:41 +02:00
|
|
|
# no parameters given -> nothing to do
|
2023-03-30 14:56:49 +02:00
|
|
|
# exit 0
|
|
|
|
#fi
|
2022-06-03 20:42:26 +02:00
|
|
|
|
2022-06-06 18:21:34 +02:00
|
|
|
if [ -z $IFS ]; then
|
|
|
|
IFS=$'\n'
|
|
|
|
fi
|
|
|
|
|
2023-05-24 16:47:54 +02:00
|
|
|
MAINTENANCE="NO"
|
2023-05-24 17:29:15 +02:00
|
|
|
WORKING_DIRECTORY=${PWD}
|
2023-05-24 16:47:54 +02:00
|
|
|
|
2022-06-03 21:48:41 +02:00
|
|
|
# parse commandline parameters
|
2022-06-06 18:21:34 +02:00
|
|
|
while test $# -gt 0; do
|
|
|
|
case $1 in
|
2023-05-24 16:47:54 +02:00
|
|
|
--maintenance | -m )
|
|
|
|
MAINTENANCE="YES"
|
|
|
|
;;
|
2022-06-06 18:21:34 +02:00
|
|
|
--file | --fil | --fi | --f | -file | -fil | -fi | -f )
|
2022-06-03 21:48:41 +02:00
|
|
|
shift
|
|
|
|
CONFIGFILENAME="$1"
|
|
|
|
;;
|
2022-06-02 17:42:35 +02:00
|
|
|
--zone | --zon | --zo | --z | -zone | -zon | -zo | -z )
|
|
|
|
shift
|
|
|
|
ZONE="$1"
|
|
|
|
;;
|
2022-06-03 21:48:41 +02:00
|
|
|
--wdir | --wdi | --wd | --w | -wdir | -wdi | -wd | -w )
|
|
|
|
shift
|
2023-06-05 15:34:46 +02:00
|
|
|
if [ "$1" = "." ]; then
|
|
|
|
WORKING_DIRECTORY="$PWD"
|
|
|
|
else
|
|
|
|
WORKING_DIRECTORY="$1"
|
|
|
|
fi
|
2022-06-06 18:21:34 +02:00
|
|
|
;;
|
|
|
|
--help | -hel | --he | --h | '--?' | -help | -hel | -he | -h | '-?' )
|
|
|
|
usage_and_exit 0
|
|
|
|
;;
|
|
|
|
--version | --versio | --versi | --vers | --ver | --ve | --v | \
|
|
|
|
-version | -versio | -versi | -vers | -ver | -ve | -v )
|
|
|
|
version
|
2022-06-03 21:48:41 +02:00
|
|
|
exit 0
|
2022-06-06 18:21:34 +02:00
|
|
|
;;
|
|
|
|
--dbg | --db | --d | -dbg | -db | -d )
|
2023-05-24 16:47:54 +02:00
|
|
|
shift
|
2022-06-06 18:21:34 +02:00
|
|
|
set_dbg_level $DEBUG
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
error "Unrecognized option: $1"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2023-06-20 09:14:20 +02:00
|
|
|
|
|
|
|
if [ -z "$WORKING_DIRECTORY" ]; then
|
|
|
|
echo "WORKING_DIRECTORY empty. exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$WORKING_DIRECTORY" ]; then
|
|
|
|
echo "WORKING_DIRECTORY $WORKING_DIRECTORY does not exist! exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$WORKING_DIRECTORY"
|
|
|
|
|
2023-05-24 17:29:15 +02:00
|
|
|
source ./update_psa_impl
|
2022-06-06 18:21:34 +02:00
|
|
|
|
2023-05-24 17:29:15 +02:00
|
|
|
if read_config; then
|
2023-05-26 15:07:13 +02:00
|
|
|
update_psa
|
|
|
|
exit 0
|
2022-06-03 20:42:26 +02:00
|
|
|
fi
|
2023-05-26 15:07:13 +02:00
|
|
|
exit 1
|
2022-06-03 21:48:41 +02:00
|
|
|
###############################################################################
|