freedomboneeee/src/freedombone-upgrade

148 lines
4.3 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
2018-04-08 14:30:21 +02:00
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
2015-12-11 12:03:56 +01:00
#
2018-04-08 14:30:21 +02:00
# Freedom in the Cloud
2015-12-11 12:03:56 +01:00
#
# Command to upgrade the system
2018-04-08 14:30:21 +02:00
#
2015-12-11 12:03:56 +01:00
# License
# =======
#
2018-01-25 19:35:39 +01:00
# Copyright (C) 2015-2018 Bob Mottram <bob@freedombone.net>
2015-12-11 12:03:56 +01:00
#
# This program is free software: you can redistribute it and/or modify
2016-02-13 23:09:27 +01:00
# it under the terms of the GNU Affero General Public License as published by
2015-12-11 12:03:56 +01:00
# 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
2016-02-13 23:09:27 +01:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
2015-12-11 12:03:56 +01:00
#
2016-02-13 23:09:27 +01:00
# 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/>.
2015-12-11 12:07:47 +01:00
PROJECT_NAME='freedombone'
2016-10-13 23:26:09 +02:00
PROJECT_DIR="$HOME/${PROJECT_NAME}"
# An optional configuration file which overrides some of these variables
2016-10-13 23:26:09 +02:00
CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
2018-06-04 16:11:00 +02:00
PROJECT_REPO="https://code.freedombone.net/bashrc/${PROJECT_NAME}"
2016-11-12 12:42:27 +01:00
CURRENT_BRANCH=master
2016-01-27 10:29:47 +01:00
# Is letsencrypt updating its certificates?
# If yes then skip the upgrade to avoid any collisions
if [ -f ~/temp_renewletsencrypt.txt ]; then
exit 0
fi
2018-03-02 20:17:02 +01:00
UTILS_FILES="/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*"
2016-10-10 11:28:37 +02:00
for f in $UTILS_FILES
do
2018-03-02 20:17:02 +01:00
source "$f"
2016-10-10 11:28:37 +02:00
done
2016-11-12 12:42:27 +01:00
2018-03-28 14:23:48 +02:00
source "/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-email"
2016-10-10 15:21:08 +02:00
read_config_param PROJECT_REPO
2018-06-09 12:47:48 +02:00
if [[ "$PROJECT_REPO" == "https://github.com/bashrc/${PROJECT_NAME}" ]]; then
PROJECT_REPO="https://code.freedombone.net/bashrc/${PROJECT_NAME}"
write_config_param PROJECT_REPO
fi
2016-11-12 12:42:27 +01:00
read_config_param DEVELOPMENT_BRANCH
2017-08-31 20:41:41 +02:00
read_config_param DEFAULT_DOMAIN_NAME
2016-11-12 12:42:27 +01:00
DEVELOPMENT_BRANCH=master
2016-11-12 12:42:27 +01:00
write_config_param "DEVELOPMENT_BRANCH" "$DEVELOPMENT_BRANCH"
if [ $DEVELOPMENT_BRANCH ]; then
if [ ${#DEVELOPMENT_BRANCH} -gt 0 ]; then
CURRENT_BRANCH=$DEVELOPMENT_BRANCH
fi
fi
# upgrading file prevents USB canary or other jobs from activating
2018-06-09 15:32:02 +02:00
rm -rf /tmp/*
touch /tmp/.upgrading
2018-03-28 16:22:30 +02:00
if [ -f /usr/bin/backupdatabases ]; then
if grep -q "cat /root/dbpass" /usr/bin/backupdatabases; then
# update to using the password manager
2018-05-02 12:22:36 +02:00
sed -i "s|cat /root/dbpass|${PROJECT_NAME}-pass -u root -a mariadb|g" /usr/bin/backupdatabases
2018-03-28 16:22:30 +02:00
fi
fi
2017-08-07 19:45:39 +02:00
#update-ca-certificates
2018-03-02 20:17:02 +01:00
if [ ! -d "$PROJECT_DIR" ]; then
git_clone "$PROJECT_REPO" "$PROJECT_DIR"
fi
2018-03-02 20:17:02 +01:00
if [ -d "$PROJECT_DIR" ]; then
if [ -f "$CONFIGURATION_FILE" ]; then
cd "$PROJECT_DIR" || exit 246823484
2018-03-03 12:49:17 +01:00
rm -rf "$PROJECT_DIR/locale/"*
2016-11-12 12:42:27 +01:00
if [[ "$CURRENT_BRANCH" == *"master" ]]; then
git_pull $PROJECT_REPO
else
git_pull $PROJECT_REPO origin/$DEVELOPMENT_BRANCH
fi
2017-06-08 12:12:05 +02:00
git checkout stretch
2016-09-29 11:28:13 +02:00
make install
if [ -d /usr/share/${PROJECT_NAME} ]; then
chown -R root:root /usr/share/${PROJECT_NAME}
chmod -R +r /usr/share/${PROJECT_NAME}
fi
2016-11-30 22:22:40 +01:00
2018-03-02 20:17:02 +01:00
if ! ${PROJECT_NAME} -c "$CONFIGURATION_FILE"; then
rm /tmp/.upgrading
2016-12-21 22:51:56 +01:00
exit 453536
fi
2016-11-30 22:22:40 +01:00
2018-03-29 12:54:44 +02:00
#rebuild_exim_with_socks
2018-05-12 18:53:21 +02:00
install_dynamicdns
torrc_migrate
2018-03-30 12:24:42 +02:00
nodejs_upgrade
apt-get -yq -t stretch-backports install certbot
2017-08-31 20:41:41 +02:00
email_install_tls
2017-11-27 23:46:29 +01:00
email_disable_chunking
2018-05-23 18:51:07 +02:00
remove_ip_addresses_from_email_logs
rm /etc/exim4/exim4.conf.template.bak*
email_update_onion_domain
prevent_mail_process_overrun
2018-05-25 16:20:26 +02:00
android_update_apps yes
2018-01-04 15:44:42 +01:00
#defrag_filesystem
2018-01-25 13:17:37 +01:00
# reinstall tor from backports
tor_version=$(tor --version)
if [[ "$tor_version" == *' 0.2'* ]]; then
2018-01-25 13:20:53 +01:00
echo 'N' | apt-get -yq -t stretch-backports install tor
2018-01-29 23:44:36 +01:00
systemctl restart tor
2018-01-25 13:17:37 +01:00
fi
2016-09-29 11:28:13 +02:00
fi
fi
# If logging was left on then turn it off
${PROJECT_NAME}-logging off
# This is a hack to fix nginx failures which happen sometimes
# when matrix is installed
if [ -d /etc/matrix ]; then
systemctl restart matrix
systemctl restart nginx
fi
# upgrading file prevents USB canary from activating
if [ -f /tmp/.upgrading ]; then
rm /tmp/.upgrading
fi
# deliberately there is no 'exit 0' here