Improve upgrades from commit changes

This commit is contained in:
Bob Mottram 2016-10-13 23:13:43 +01:00
parent 784c572279
commit a3f7ab9fae
3 changed files with 61 additions and 71 deletions

View File

@ -94,8 +94,10 @@ function upgrade_rss {
if [[ $(app_is_installed rss) == "1" ]]; then if [[ $(app_is_installed rss) == "1" ]]; then
function_check set_repo_commit function_check set_repo_commit
set_repo_commit $RSS_READER_PATH "rss reader commit" "$RSS_READER_COMMIT" $RSS_READER_REPO set_repo_commit $RSS_READER_PATH "rss reader commit" "$RSS_READER_COMMIT" $RSS_READER_REPO
function_check rss_modifications if [[ $(commit_has_changed $RSS_READER_PATH "rss reader commit" "$RSS_READER_COMMIT") == "1" ]]; then
rss_modifications function_check rss_modifications
rss_modifications
fi
fi fi
if [[ $(app_is_installed rss_mobile_reader) == "1" ]]; then if [[ $(app_is_installed rss_mobile_reader) == "1" ]]; then

View File

@ -145,9 +145,24 @@ function reconfigure_tox {
function upgrade_tox { function upgrade_tox {
function_check set_repo_commit function_check set_repo_commit
set_repo_commit $INSTALL_DIR/toxcore "toxcore commit" "$TOXCORE_COMMIT" $TOXCORE_REPO set_repo_commit $INSTALL_DIR/toxcore "toxcore commit" "$TOXCORE_COMMIT" $TOXCORE_REPO
if [[ $(commit_has_changed $INSTALL_DIR/toxcore "toxcore commit" "$TOXCORE_COMMIT") == "1" ]]; then
cd $INSTALL_DIR/toxcore
sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
autoreconf -i
./configure --enable-daemon
make
make install
systemctl daemon-reload
systemctl restart tox-bootstrapd.service
fi
function_check set_repo_commit function_check set_repo_commit
set_repo_commit $INSTALL_DIR/toxic "Toxic commit" "$TOXIC_COMMIT" $TOXIC_REPO set_repo_commit $INSTALL_DIR/toxic "Toxic commit" "$TOXIC_COMMIT" $TOXIC_REPO
if [[ $(commit_has_changed $INSTALL_DIR/toxic "Toxic commit" "$TOXIC_COMMIT") == "1" ]]; then
cd $INSTALL_DIR/toxic
make
make install
fi
} }
function backup_local_tox { function backup_local_tox {

View File

@ -32,7 +32,7 @@ function git_clone {
repo_url="$1" repo_url="$1"
destination_dir="$2" destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then if [[ "$repo_url" == 'ssh:'* ]]; then
retval=$(get_friends_servers) retval=$(get_friends_servers)
if [[ $retval == "0" ]]; then if [[ $retval == "0" ]]; then
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
@ -88,6 +88,21 @@ function git_pull {
fi fi
} }
function commit_has_changed {
repo_dir=$1
repo_commit_name=$2
repo_commit=$3
if [ -d $repo_dir ]; then
if grep -q "$repo_commit_name" $COMPLETION_FILE; then
CURRENT_REPO_COMMIT=$(grep "$repo_commit_name" $COMPLETION_FILE | awk -F ':' '{print $2}')
if [[ "$CURRENT_REPO_COMMIT" != "$repo_commit" ]]; then
echo "1"
fi
fi
fi
echo "0"
}
# This ensures that a given repo is on a given commit # This ensures that a given repo is on a given commit
# If it isn't then it attempts to upgrade # If it isn't then it attempts to upgrade
function set_repo_commit { function set_repo_commit {
@ -95,77 +110,35 @@ function set_repo_commit {
repo_commit_name=$2 repo_commit_name=$2
repo_commit=$3 repo_commit=$3
repo_url=$4 repo_url=$4
if [ -d $repo_dir ]; then
if grep -q "$repo_commit_name" $COMPLETION_FILE; then
CURRENT_REPO_COMMIT=$(grep "$repo_commit_name" $COMPLETION_FILE | awk -F ':' '{print $2}')
if [[ "$CURRENT_REPO_COMMIT" != "$repo_commit" ]]; then
cd $repo_dir
git_pull $repo_url $repo_commit
# application specific stuff after updating the repo if [[ $(commit_has_changed $repo_dir $repo_commit_name $repo_commit) == "1" ]]; then
if [[ $repo_dir == *"www"* ]]; then cd $repo_dir
chown -R www-data:www-data $repo_dir git_pull $repo_url $repo_commit
fi
if [[ $repo_dir == *"cjdns" ]]; then
./do
fi
if [[ $repo_dir == *"gpgit" ]]; then
cp gpgit.pl /usr/bin/gpgit.pl
fi
if [[ $repo_dir == *"cleanup-maildir" ]]; then
cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin
fi
if [[ $repo_dir == *"nginx_ensite" ]]; then
make install
fi
if [[ $repo_dir == *"gogs" ]]; then
git checkout master
go get -u ./...
if [ ! "$?" = "0" ]; then
echo $'Failed to get gogs'
exit 52792
fi
git checkout $repo_commit
go build
if [ ! "$?" = "0" ]; then
echo $'Failed to build gogs'
exit 36226
fi
systemctl restart gogs
fi
if [[ $repo_dir == *"toxcore" ]]; then
sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
autoreconf -i
./configure --enable-daemon
make
make install
systemctl daemon-reload
systemctl restart tox-bootstrapd.service
fi
if [[ $repo_dir == *"toxic" ]]; then
make
make install
fi
if [[ $repo_dir == $RSS_READER_PATH ]]; then
function_check rss_reader_modifications
rss_reader_modifications
fi
if [[ $repo_dir == *"inadyn" ]]; then
./configure
USE_OPENSSL=1 make
make install
systemctl restart inadyn
fi
if [[ $repo_dir == *"ipfs" ]]; then
chown -R git:git /home/git
systemctl restart ipfs
systemctl daemon-reload
fi
sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE # application specific stuff after updating the repo
fi if [[ $repo_dir == *"www"* ]]; then
else chown -R www-data:www-data $repo_dir
fi
if [[ $repo_dir == *"gpgit" ]]; then
cp gpgit.pl /usr/bin/gpgit.pl
fi
if [[ $repo_dir == *"cleanup-maildir" ]]; then
cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin
fi
if [[ $repo_dir == *"nginx_ensite" ]]; then
make install
fi
if [[ $repo_dir == *"inadyn" ]]; then
./configure
USE_OPENSSL=1 make
make install
systemctl restart inadyn
fi
if ! grep -q "${repo_commit_name}:" $COMPLETION_FILE; then
echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
else
sed -i "s/${repo_commit_name}.*/${repo_commit_name}:$repo_commit/g" $COMPLETION_FILE
fi fi
fi fi
} }