freedombone/src/freedombone-upgrade

118 lines
3.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2015-12-11 12:03:56 +01:00
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Command to upgrade the system
# License
# =======
#
2016-10-31 17:24:49 +01:00
# Copyright (C) 2015-2016 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"
PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
2016-02-01 11:05:29 +01:00
FRIENDS_MIRRORS_SERVER=
FRIENDS_MIRRORS_SSH_PORT=2222
2016-02-01 11:05:29 +01:00
FRIENDS_MIRRORS_PASSWORD=
MY_MIRRORS_PASSWORD=
2016-11-12 12:42:27 +01:00
CURRENT_BRANCH=master
2016-01-27 10:29:47 +01:00
2017-01-03 15:26:45 +01:00
# clear temporary files
rm -rf /tmp/*
2016-10-10 11:28:37 +02:00
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
for f in $UTILS_FILES
do
2016-11-12 12:06:51 +01:00
source $f
2016-10-10 11:28:37 +02:00
done
2016-11-12 12:42:27 +01:00
2016-10-10 15:21:08 +02:00
read_config_param PROJECT_REPO
2016-11-12 12:42:27 +01:00
read_config_param DEVELOPMENT_BRANCH
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
if grep "cat /root/dbpass" /usr/bin/backupdatabases; then
# update to using the password manager
sed -i "s|cat /root/dbpass|freedombone-pass -u root -a mariadb|g" /usr/bin/backupdatabases
fi
update-ca-certificates
2016-01-27 10:29:47 +01:00
read_repo_servers
${PROJECT_NAME}-mirrors
2016-01-27 10:29:47 +01:00
if [ ! -d $PROJECT_DIR ]; then
2016-11-12 12:42:27 +01:00
git_clone $PROJECT_REPO $PROJECT_DIR
fi
if [ -d $PROJECT_DIR ]; then
2016-09-29 11:28:13 +02:00
if [ -f $CONFIGURATION_FILE ]; then
cd $PROJECT_DIR
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
2016-09-29 11:28:13 +02:00
${PROJECT_NAME} -c $CONFIGURATION_FILE
2016-12-21 22:51:56 +01:00
if [ ! "$?" = "0" ]; then
lockdown_permissions
exit 453536
fi
2016-11-30 22:22:40 +01:00
lockdown_permissions
2017-06-12 15:02:19 +02:00
defrag_filesystem
2016-09-29 11:28:13 +02:00
fi
fi
# If logging was left on then turn it off
${PROJECT_NAME}-logging off
2016-07-03 22:49:38 +02:00
if [ -f /usr/bin/reset-tripwire ]; then
2016-09-29 11:28:13 +02:00
echo '
' | reset-tripwire
2016-07-03 22:49:38 +02:00
fi
# deliberately there is no 'exit 0' here