-
Bob Mottram authoredBob Mottram authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
freedombone-addremove 2.31 KiB
#!/bin/bash
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
#
# Freedom in the Cloud
#
# Add or remove apps
#
# This is a wrapper which catches the exit state from the base script
# and alters the webadmin index screen if needed
#
# License
# =======
#
# Copyright (C) 2015-2018 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
arg1="$1"
arg2="$2"
adding_app_file=/root/.addremove_app_command
if [ -f "$adding_app_file" ]; then
rm "$adding_app_file"
fi
if [[ "$arg1" == 'add' ]]; then
if [ "$arg2" ]; then
touch "$adding_app_file"
fi
fi
/usr/local/bin/freedombone-addremove-base "$arg1" "$arg2" || \
(
echo $'addremove fail state'
if [ -f "$adding_app_file" ]; then
echo $'Failed to add app'
rm "$adding_app_file"
local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local
webadmin_install_dir="/var/www/${local_hostname}/htdocs/admin"
pending_installs="$webadmin_install_dir/pending_installs.txt"
# show the installation failed screen
sed -i "/install_$arg2/d" "$pending_installs"
#web_admin_create_add_apps
cp "$webadmin_install_dir/app_installing_failed.html" "$webadmin_install_dir/index.html"
cp "$webadmin_install_dir/app_installing_failed.html" "$webadmin_install_dir/installing_progress.html"
exit 1
else
exit 0
fi
)
if [ -f "$adding_app_file" ]; then
rm "$adding_app_file"
fi
exit 0