2015-11-30 18:52:39 +01:00
|
|
|
#!/bin/bash
|
2015-12-11 12:03:56 +01:00
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# Command to upgrade the system
|
|
|
|
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2016-01-02 22:58:27 +01:00
|
|
|
# Copyright (C) 2015-2016 Bob Mottram <bob@robotics.uk.to>
|
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-11-30 18:52:39 +01:00
|
|
|
|
2015-12-11 12:07:47 +01:00
|
|
|
PROJECT_NAME='freedombone'
|
|
|
|
|
2016-01-25 18:45:37 +01:00
|
|
|
PROJECT_DIR="/root/${PROJECT_NAME}"
|
|
|
|
|
|
|
|
# An optional configuration file which overrides some of these variables
|
|
|
|
CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"
|
|
|
|
|
|
|
|
PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
|
|
|
|
|
2016-02-01 11:05:29 +01:00
|
|
|
FRIENDS_MIRRORS_SERVER=
|
2016-02-01 12:57:35 +01:00
|
|
|
FRIENDS_MIRRORS_SSH_PORT=2222
|
2016-02-01 11:05:29 +01:00
|
|
|
FRIENDS_MIRRORS_PASSWORD=
|
|
|
|
MY_MIRRORS_PASSWORD=
|
2016-01-27 10:29:47 +01:00
|
|
|
|
2016-07-06 21:27:18 +02:00
|
|
|
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-git
|
2016-06-30 15:59:43 +02:00
|
|
|
|
2016-01-27 10:29:47 +01:00
|
|
|
function read_repo_servers {
|
2016-09-29 11:28:13 +02:00
|
|
|
if [ -f $CONFIGURATION_FILE ]; then
|
|
|
|
if grep -q "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE; then
|
|
|
|
FRIENDS_MIRRORS_SERVER=$(grep "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
|
|
|
fi
|
|
|
|
if grep -q "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE; then
|
|
|
|
FRIENDS_MIRRORS_SSH_PORT=$(grep "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
|
|
|
fi
|
|
|
|
if grep -q "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
|
|
|
|
MY_MIRRORS_PASSWORD=$(grep "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
|
|
|
fi
|
|
|
|
if grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
|
|
|
|
FRIENDS_MIRRORS_PASSWORD=$(grep "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
MAIN_COMMAND=/usr/local/bin/${PROJECT_NAME}
|
|
|
|
if [ ! -f $MAIN_COMMAND ]; then
|
|
|
|
MAIN_COMMAND=/usr/bin/${PROJECT_NAME}
|
|
|
|
fi
|
|
|
|
|
|
|
|
REPOS=($(cat ${MAIN_COMMAND} | grep "_REPO=\"" | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
|
|
|
|
|
|
|
|
for line in "${REPOS[@]}"
|
|
|
|
do
|
|
|
|
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
|
|
|
|
mirrors_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
|
|
|
|
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
|
|
|
|
${repo_name}="${friends_repo_url}"
|
|
|
|
done
|
2016-01-27 10:29:47 +01:00
|
|
|
}
|
|
|
|
|
2016-01-25 18:45:37 +01:00
|
|
|
if [ -f $CONFIGURATION_FILE ]; then
|
2016-09-29 11:28:13 +02:00
|
|
|
# read the location of the main project repo
|
|
|
|
if grep -q "PROJECT_REPO" $CONFIGURATION_FILE; then
|
|
|
|
PROJECT_REPO=$(grep "PROJECT_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
|
|
|
fi
|
2016-01-25 18:45:37 +01:00
|
|
|
fi
|
2015-11-30 18:52:39 +01:00
|
|
|
|
|
|
|
update-ca-certificates
|
|
|
|
|
2016-01-27 10:29:47 +01:00
|
|
|
read_repo_servers
|
2016-02-01 12:57:35 +01:00
|
|
|
${PROJECT_NAME}-mirrors
|
2016-01-27 10:29:47 +01:00
|
|
|
|
2016-01-25 18:45:37 +01:00
|
|
|
if [ ! -d $PROJECT_DIR ]; then
|
2016-09-29 11:28:13 +02:00
|
|
|
git_clone $PROJECT_REPO $PROJECT_DIR
|
2015-11-30 18:52:39 +01:00
|
|
|
fi
|
|
|
|
|
2016-01-25 18:45:37 +01:00
|
|
|
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/*
|
|
|
|
git checkout stockholm
|
|
|
|
git_pull $PROJECT_REPO
|
|
|
|
make install
|
|
|
|
${PROJECT_NAME} -c $CONFIGURATION_FILE
|
|
|
|
fi
|
2015-11-30 18:52:39 +01:00
|
|
|
fi
|
|
|
|
|
2016-07-03 22:49:38 +02:00
|
|
|
if [ -f /usr/bin/reset-tripwire ]; then
|
2016-09-29 11:28:13 +02:00
|
|
|
echo '
|
2015-11-30 18:52:39 +01:00
|
|
|
|
|
|
|
' | reset-tripwire
|
2016-07-03 22:49:38 +02:00
|
|
|
fi
|
2015-11-30 18:52:39 +01:00
|
|
|
|
|
|
|
# deliberately there is no 'exit 0' here
|