Simplify install state checking

This commit is contained in:
Bob Mottram 2016-10-01 17:38:07 +01:00
parent 816f83d78d
commit 4956701174
26 changed files with 49 additions and 130 deletions

View File

@ -100,9 +100,6 @@ function configure_firewall_for_babel {
} }
function install_babel { function install_babel {
if [[ $(app_is_installed babel) == "1" ]]; then
return
fi
if [[ $ENABLE_BABEL != "yes" ]]; then if [[ $ENABLE_BABEL != "yes" ]]; then
return return
fi fi
@ -115,7 +112,6 @@ function install_babel {
function_check configure_firewall_for_babel function_check configure_firewall_for_babel
configure_firewall_for_babel configure_firewall_for_babel
install_completed babel
} }
# NOTE: deliberately there is no "exit 0" # NOTE: deliberately there is no "exit 0"

View File

@ -135,9 +135,6 @@ function install_batman {
mesh_install_batman mesh_install_batman
return return
fi fi
if [[ $(app_is_installed batman) == "1" ]]; then
return
fi
if [[ $ENABLE_BATMAN != "yes" ]]; then if [[ $ENABLE_BATMAN != "yes" ]]; then
return return
fi fi
@ -162,7 +159,6 @@ function install_batman {
function_check configure_firewall_for_batman function_check configure_firewall_for_batman
configure_firewall_for_batman configure_firewall_for_batman
install_completed batman
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -590,10 +590,6 @@ function install_blog_from_repo {
} }
function install_blog { function install_blog {
if [[ $(app_is_installed blog) == "1" ]]; then
return
fi
if [ ! $ONION_ONLY ]; then if [ ! $ONION_ONLY ]; then
ONION_ONLY='no' ONION_ONLY='no'
fi fi
@ -675,8 +671,6 @@ function install_blog {
if ! grep -q "Blog domain:" $COMPLETION_FILE; then if ! grep -q "Blog domain:" $COMPLETION_FILE; then
echo "Blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE echo "Blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
fi fi
install_completed blog
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -305,10 +305,6 @@ function install_blogstatic {
return return
fi fi
if [[ $(app_is_installed blogstatic) == "1" ]]; then
return
fi
apt-get -y install python-pip apt-get -y install python-pip
pip install ipython pip install ipython
pip install Markdown pip install Markdown
@ -342,8 +338,6 @@ function install_blogstatic {
chown -R $MY_USERNAME:$MY_USERNAME $STATIC_BLOG_INSTALL_DIR chown -R $MY_USERNAME:$MY_USERNAME $STATIC_BLOG_INSTALL_DIR
chown -R www-data:www-data $STATIC_BLOG_PATH chown -R www-data:www-data $STATIC_BLOG_PATH
install_completed blogstatic
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -529,13 +529,10 @@ function install_cjdns_tools {
# initialise from the cjdns config # initialise from the cjdns config
/usr/bin/cjdcmd cjdnsadmin -file /etc/cjdns/cjdroute.conf /usr/bin/cjdcmd cjdnsadmin -file /etc/cjdns/cjdroute.conf
echo 'install_cjdns_tools' >> $COMPLETION_FILE install_completed cjdns_tools
} }
function install_cjdns { function install_cjdns {
if [[ $(app_is_installed cjdns) == "1" ]]; then
return
fi
install_cjdns_main install_cjdns_main
install_cjdns_tools install_cjdns_tools
install_completed cjdns install_completed cjdns

View File

@ -257,12 +257,8 @@ function script_for_attaching_usb_drive {
} }
function install_dlna { function install_dlna {
if [[ $(app_is_installed dlna) == "1" ]]; then
return
fi
install_dlna_main install_dlna_main
script_for_attaching_usb_drive script_for_attaching_usb_drive
install_completed dlna
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -108,9 +108,6 @@ function remove_emacs {
} }
function install_emacs { function install_emacs {
if [[ $(app_is_installed emacs) == "1" ]]; then
return
fi
update-alternatives --set editor /usr/bin/emacs24 update-alternatives --set editor /usr/bin/emacs24
# A minimal emacs configuration # A minimal emacs configuration
@ -185,8 +182,6 @@ function install_emacs {
echo '(epa-file-enable)' >> /home/$MY_USERNAME/.emacs echo '(epa-file-enable)' >> /home/$MY_USERNAME/.emacs
cp /home/$MY_USERNAME/.emacs /root/.emacs cp /home/$MY_USERNAME/.emacs /root/.emacs
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs
install_completed emacs
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -1011,10 +1011,6 @@ function install_gnusocial_plugin_nsfw {
} }
function install_gnusocial { function install_gnusocial {
if [[ $(app_is_installed gnusocial) == "1" ]]; then
return
fi
if [ ! $ONION_ONLY ]; then if [ ! $ONION_ONLY ]; then
ONION_ONLY='no' ONION_ONLY='no'
fi fi
@ -1044,7 +1040,6 @@ function install_gnusocial {
install_gnusocial_plugin_sharings install_gnusocial_plugin_sharings
install_gnusocial_plugin_sharings_theme install_gnusocial_plugin_sharings_theme
install_gnusocial_plugin_nsfw install_gnusocial_plugin_nsfw
install_completed gnusocial
} }
# NOTE: deliberately there is no "exit 0" # NOTE: deliberately there is no "exit 0"

View File

@ -442,10 +442,6 @@ function install_gogs {
return return
fi fi
if [[ $(app_is_installed gogs) == "1" ]]; then
return
fi
adduser --disabled-login --gecos 'Gogs' $GOGS_USERNAME adduser --disabled-login --gecos 'Gogs' $GOGS_USERNAME
gogs_parameters gogs_parameters
@ -766,7 +762,6 @@ function install_gogs {
else else
sed -i "s|Gogs version.*|Gogs version:$GOGS_VERSION|g" $COMPLETION_FILE sed -i "s|Gogs version.*|Gogs version:$GOGS_VERSION|g" $COMPLETION_FILE
fi fi
install_completed gogs
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -400,10 +400,6 @@ function install_hubzilla {
return return
fi fi
if [[ $(app_is_installed hubzilla) == "1" ]]; then
return
fi
HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs HUBZILLA_PATH=/var/www/$HUBZILLA_DOMAIN_NAME/htdocs
function_check install_mariadb function_check install_mariadb
@ -704,7 +700,6 @@ function install_hubzilla {
${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$HUBZILLA_DOMAIN_NAME" -g hubzilla --public no ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$HUBZILLA_DOMAIN_NAME" -g hubzilla --public no
echo "Hubzilla domain:${HUBZILLA_DOMAIN_NAME}" >> $COMPLETION_FILE echo "Hubzilla domain:${HUBZILLA_DOMAIN_NAME}" >> $COMPLETION_FILE
install_completed hubzilla
} }
# NOTE: deliberately there is no "exit 0" # NOTE: deliberately there is no "exit 0"

View File

@ -371,12 +371,8 @@ function install_irc_client {
} }
function install_irc { function install_irc {
if [[ $(app_is_installed irc) == "1" ]]; then
return
fi
install_irc_server install_irc_server
install_irc_client install_irc_client
install_completed irc
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -231,10 +231,6 @@ function install_librevault {
return return
fi fi
if [[ $(app_is_installed librevault) == "1" ]]; then
return
fi
install_tracker install_tracker
install_cmake install_cmake
install_cryptopp install_cryptopp
@ -326,8 +322,6 @@ function install_librevault {
systemctl enable librevault-daemon systemctl enable librevault-daemon
systemctl start librevault-daemon systemctl start librevault-daemon
install_completed librevault
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -128,7 +128,34 @@ function reconfigure_mediagoblin {
} }
function upgrade_mediagoblin { function upgrade_mediagoblin {
echo -n '' if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE; then
MEDIAGOBLIN_DOMAIN_NAME=$(grep "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE; then
MEDIAGOBLIN_CODE=$(grep "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if [ ! $MEDIAGOBLIN_DOMAIN_NAME ]; then
return
fi
MEDIAGOBLIN_WORKING_DIRECTORY=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
# update to a new commit if needed
function_check set_repo_commit
set_repo_commit $MEDIAGOBLIN_WORKING_DIRECTORY "Mediagoblin commit" "$MEDIAGOBLIN_COMMIT" $MEDIAGOBLIN_REPO
if [ -d $MEDIAGOBLIN_WORKING_DIRECTORY ]; then
chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY
fi
} }
function backup_local_mediagoblin { function backup_local_mediagoblin {
@ -209,10 +236,6 @@ function install_mediagoblin {
chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY
fi fi
if [[ $(app_is_installed mediagoblin) == "1" ]]; then
return
fi
apt-get -y install git-core python python-dev python-lxml python-pil apt-get -y install git-core python python-dev python-lxml python-pil
apt-get -y install python-virtualenv npm nodejs-legacy automake apt-get -y install python-virtualenv npm nodejs-legacy automake
apt-get -y install fcgiwrap apt-get -y install fcgiwrap
@ -531,8 +554,6 @@ function install_mediagoblin {
else else
sed -i "s/Mediagoblin domain.*/Mediagoblin domain:$MEDIAGOBLIN_DOMAIN_NAME/g" $COMPLETION_FILE sed -i "s/Mediagoblin domain.*/Mediagoblin domain:$MEDIAGOBLIN_DOMAIN_NAME/g" $COMPLETION_FILE
fi fi
install_completed mediagoblin
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -199,9 +199,6 @@ function configure_firewall_for_voip {
} }
function install_mumble { function install_mumble {
if [[ $(app_is_installed mumble) == "1" ]]; then
return
fi
apt-get -y install mumble-server apt-get -y install mumble-server
function_check get_voip_server_password function_check get_voip_server_password
@ -289,7 +286,6 @@ function install_mumble {
function_check configure_firewall_for_voip function_check configure_firewall_for_voip
configure_firewall_for_voip configure_firewall_for_voip
install_completed mumble
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -617,13 +617,9 @@ function install_rss_mobile_reader {
} }
function install_rss { function install_rss {
if [[ $(app_is_installed rss) == "1" ]]; then
return
fi
install_rss_main install_rss_main
install_rss_gnusocial install_rss_gnusocial
install_rss_mobile_reader install_rss_mobile_reader
install_completed rss
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -122,10 +122,6 @@ function install_searx {
exit 62429 exit 62429
fi fi
if [[ $(app_is_installed searx) == "1" ]]; then
return
fi
apt-get -y install python-pip libyaml-dev python-werkzeug python-babel python-lxml apache2-utils apt-get -y install python-pip libyaml-dev python-werkzeug python-babel python-lxml apache2-utils
apt-get -y install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev uwsgi uwsgi-plugin-python libapache2-mod-uwsgi apt-get -y install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev uwsgi uwsgi-plugin-python libapache2-mod-uwsgi
@ -292,8 +288,6 @@ function install_searx {
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
install_completed searx
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -446,12 +446,8 @@ function install_sip_turn {
} }
function install_sip { function install_sip {
if [[ $(app_is_installed sip) == "1" ]]; then
return
fi
install_sip_main install_sip_main
update_sipwitch_daemon update_sipwitch_daemon
install_completed sip
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -470,10 +470,6 @@ function install_syncthing {
return return
fi fi
if [[ $(app_is_installed syncthing) == "1" ]]; then
return
fi
apt-get -y install curl apt-get -y install curl
curl -s https://syncthing.net/release-key.txt | apt-key add - curl -s https://syncthing.net/release-key.txt | apt-key add -
@ -508,7 +504,6 @@ function install_syncthing {
function_check configure_firewall_for_syncthing function_check configure_firewall_for_syncthing
configure_firewall_for_syncthing configure_firewall_for_syncthing
install_completed syncthing
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -292,10 +292,6 @@ function install_tahoelafs {
return return
fi fi
if [[ $(app_is_installed tahoelafs) == "1" ]]; then
return
fi
apt-get -y install build-essential python-pip python-dev libffi-dev libssl-dev python-virtualenv apt-get -y install build-essential python-pip python-dev libffi-dev libssl-dev python-virtualenv
# create a user to run the introducer # create a user to run the introducer
@ -357,8 +353,6 @@ function install_tahoelafs {
systemctl enable tahoelafs systemctl enable tahoelafs
systemctl daemon-reload systemctl daemon-reload
systemctl start tahoelafs systemctl start tahoelafs
install_completed tahoelafs
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -661,12 +661,6 @@ function enable_tox_repo {
} }
function install_tox { function install_tox {
if [ ! $INSTALLING_MESH ]; then
if [[ $(app_is_installed tox) == "1" ]]; then
return
fi
fi
configure_firewall_for_tox configure_firewall_for_tox
if [ $INSTALLING_MESH ]; then if [ $INSTALLING_MESH ]; then
@ -678,8 +672,6 @@ function install_tox {
tox_avahi tox_avahi
install_tox_client install_tox_client
fi fi
install_completed tox
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -68,9 +68,6 @@ function remove_vpn {
} }
function install_vpn { function install_vpn {
if [[ $(app_is_installed vpn) == "1" ]]; then
return
fi
if ! grep -q "repo.universe-factory.net" /etc/apt/sources.list; then if ! grep -q "repo.universe-factory.net" /etc/apt/sources.list; then
echo 'deb http://repo.universe-factory.net/debian/ sid main' >> /etc/apt/sources.list echo 'deb http://repo.universe-factory.net/debian/ sid main' >> /etc/apt/sources.list
gpg --keyserver pgpkeys.mit.edu --recv-key 16EF3F64CB201D9C gpg --keyserver pgpkeys.mit.edu --recv-key 16EF3F64CB201D9C
@ -84,7 +81,6 @@ function install_vpn {
exit 52026 exit 52026
fi fi
fi fi
install_completed vpn
} }
# NOTE: deliberately there is no "exit 0" # NOTE: deliberately there is no "exit 0"

View File

@ -138,9 +138,6 @@ function remove_webmail {
} }
function install_webmail { function install_webmail {
if [[ $(app_is_installed webmail) == "1" ]]; then
return
fi
if [ -d /etc/apache2 ]; then if [ -d /etc/apache2 ]; then
rm -rf /etc/apache2 rm -rf /etc/apache2
echo $'Removed Apache installation after Dokuwiki install' echo $'Removed Apache installation after Dokuwiki install'
@ -259,8 +256,6 @@ function install_webmail {
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
install_completed webmail
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -270,10 +270,6 @@ function get_wiki_admin_password {
} }
function install_wiki { function install_wiki {
if [[ $(app_is_installed wiki) == "1" ]]; then
return
fi
if [ ! $ONION_ONLY ]; then if [ ! $ONION_ONLY ]; then
ONION_ONLY='no' ONION_ONLY='no'
fi fi
@ -657,7 +653,6 @@ function install_wiki {
fi fi
echo "Wiki domain:$WIKI_DOMAIN_NAME" >> $COMPLETION_FILE echo "Wiki domain:$WIKI_DOMAIN_NAME" >> $COMPLETION_FILE
install_completed wiki
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -502,12 +502,8 @@ function install_xmpp_client {
} }
function install_xmpp { function install_xmpp {
if [[ $(app_is_installed xmpp) == "1" ]]; then
return
fi
install_xmpp_main install_xmpp_main
install_xmpp_client install_xmpp_client
install_completed xmpp
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -675,14 +675,10 @@ function install_zeronet {
mesh_zeronet_forum mesh_zeronet_forum
return return
fi fi
if [[ $(app_is_installed zeronet) == "1" ]]; then
return
fi
install_zeronet_main install_zeronet_main
install_zeronet_blog install_zeronet_blog
install_zeronet_mail install_zeronet_mail
install_zeronet_forum install_zeronet_forum
install_completed zeronet
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0

View File

@ -310,15 +310,29 @@ function install_apps {
# clears any removal indicator # clears any removal indicator
reinstall_app ${a} reinstall_app ${a}
if [[ $(app_is_installed ${a}) == "1" ]]; then
echo $"Upgrading application from interactive: ${a}"
upgrade_${a}
echo $"${a} was upgraded from interactive"
else
echo $"Installing application from interactive: ${a}" echo $"Installing application from interactive: ${a}"
install_${a} install_${a}
install_completed ${a}
echo $"${a} was installed from interactive" echo $"${a} was installed from interactive"
fi
else else
# check if the app was removed # check if the app was removed
if [[ $(app_is_removed ${a}) == "0" ]]; then if [[ $(app_is_removed ${a}) == "0" ]]; then
if [[ $(app_is_installed ${a}) == "1" ]]; then
echo $"Upgrading application: ${a}"
upgrade_${a}
echo $"${a} was upgraded"
else
echo $"Installing application: ${a}" echo $"Installing application: ${a}"
install_${a} install_${a}
install_completed ${a}
echo $"${a} was installed" echo $"${a} was installed"
fi
else else
echo $"${a} has been removed and so will not be reinstalled" echo $"${a} has been removed and so will not be reinstalled"
fi fi