ALl that is left is now we must actually do the sym links

This commit is contained in:
Stephen Cochrane 2020-10-15 10:40:07 +02:00
parent 9d37f1985b
commit 59a23c3866
1 changed files with 21 additions and 9 deletions

30
nginxd
View File

@ -29,7 +29,19 @@ link () {
ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/$1 ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/$1
} }
# Enable or disable all units # Adds a unit so that nginx can use it, also sets up sym links.
# add [unit]
add () {
echo TODO: Enable $1
}
# Remove a unit so that nginx does not use it anymore, also sets up sym links.
# remove [unit]
remove () {
echo TODO: Remove $1
}
# Enable or disable all units.
# all [ a | d ] # all [ a | d ]
all () { all () {
@ -62,7 +74,7 @@ all () {
echo "Adding units ( ${ADD[@]} )" echo "Adding units ( ${ADD[@]} )"
echo "Removing units ( ${REMOVE[@]} )" echo "Removing units ( ${REMOVE[@]} )"
echo TODO: Add and remove units using ADD,REMOVE echo TODO: Add and remove units using add,remove
} }
# Handle arguments and do basic error checking # Handle arguments and do basic error checking
@ -99,20 +111,20 @@ unitsd=$(echo $unitsd | sed 's:/*$::') # Remove trailing slash
|| echo "Unit <$unit> is supported!" || echo "Unit <$unit> is supported!"
# Check if we are disabeling, that we have a replacement unit # Check if we are disabeling, that we have a replacement unit
[ $oper == "d" ] && [[ ! -f "$unitsd/d$unit" ]] && error "Cannot find replacement unit for <$unit>." 1 [ $oper == "d" ] && [ $unit != "all" ] && [[ ! -f "$unitsd/d$unit" ]] && error "Cannot find replacement unit for <$unit>." 1
[ $oper == "e" ] && [ $unit != "all" ] && [[ ! -f "$unitsd/$unit" ]] && error "Cannot find unit file for <$unit>" 1 [ $oper == "e" ] && [ $unit != "all" ] && [[ ! -f "$unitsd/$unit" ]] && error "Cannot find unit file for <$unit>" 1
# Everything is valid, start setting up. # Everything is valid, Perform tasks
echo TODO: Setup links, and delete links if needed if [ $unit == "all" ]
# Perform tasks
if [ $unit == "all"]
then then
all $oper all $oper
elif [ $oper == 'e' ] elif [ $oper == 'e' ]
then then
echo Enabling $unit add $unit
remove "d$unit"
elif [ $oper == 'd' ] elif [ $oper == 'd' ]
add "d$unit"
remove $unit
then then
echo Disabling $unit echo Disabling $unit
else else