From 5064ca9413864405b847582767d738410ca6479b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Jan 2016 10:53:03 +0000 Subject: [PATCH] Set repo origin on pull In order to handle trove changes --- src/freedombone | 51 ++++++++++++++++++++++------------------- src/freedombone-addcert | 15 ++++++++---- src/freedombone-upgrade | 15 +++++++++++- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/src/freedombone b/src/freedombone index 1376d7ab..f08fcd9d 100755 --- a/src/freedombone +++ b/src/freedombone @@ -556,15 +556,20 @@ function git_clone { } function git_pull { + if [ ! $1 ]; then + echo $'git_pull no repo specified' + fi + git stash + git remote set-url origin $1 git checkout master if [ "${FRIENDS_TROVE_SERVER}" ]; then if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then if [ "$FRIENDS_TROVE_PASSWORD" ]; then if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then sshpass -p "$FRIENDS_TROVE_PASSWORD" git pull - if [ $1 ]; then - git checkout $1 -b $1 + if [ $2 ]; then + git checkout $2 -b $2 fi return fi @@ -573,8 +578,8 @@ function git_pull { fi git pull - if [ $1 ]; then - git checkout $1 -b $1 + if [ $2 ]; then + git checkout $2 -b $2 fi } @@ -1974,7 +1979,7 @@ function mesh_cjdns { CURRENT_CJDNS_COMMIT=$(grep "cjdns commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_CJDNS_COMMIT" != "$CJDNS_COMMIT" ]]; then cd /etc/cjdns - git_pull $CJDNS_COMMIT + git_pull $CJDNS_REPO $CJDNS_COMMIT sed -i "s/cjdns commit.*/cjdns commit:$CJDNS_COMMIT/g" $COMPLETION_FILE ./do fi @@ -2026,7 +2031,7 @@ function mesh_cjdns { useradd cjdns else cd /etc/cjdns - git_pull + git_pull $CJDNS_REPO ./do if [ ! "$?" = "0" ]; then exit 9926 @@ -2309,7 +2314,7 @@ function install_zeronet_blog { CURRENT_ZERONET_BLOG_COMMIT=$(grep "ZeroNet Blog commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_ZERONET_BLOG_COMMIT" != "$ZERONET_BLOG_COMMIT" ]]; then cd /opt/zeronet/ZeroBlog - git_pull $ZERONET_BLOG_COMMIT + git_pull $ZERONET_BLOG_REPO $ZERONET_BLOG_COMMIT sed -i "s/ZeroNet Blog commit.*/ZeroNet Blog commit:$ZERONET_BLOG_COMMIT/g" $COMPLETION_FILE fi else @@ -2432,7 +2437,7 @@ function install_zeronet_mail { CURRENT_ZERONET_MAIL_COMMIT=$(grep "ZeroNet Mail commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_ZERONET_MAIL_COMMIT" != "$ZERONET_MAIL_COMMIT" ]]; then cd /opt/zeronet/ZeroMail - git_pull $ZERONET_MAIL_COMMIT + git_pull $ZERONET_MAIL_REPO $ZERONET_MAIL_COMMIT sed -i "s/ZeroNet Mail commit.*/ZeroNet Mail commit:$ZERONET_MAIL_COMMIT/g" $COMPLETION_FILE fi else @@ -2556,7 +2561,7 @@ function install_zeronet_forum { CURRENT_ZERONET_FORUM_COMMIT=$(grep "ZeroNet Forum commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_ZERONET_FORUM_COMMIT" != "$ZERONET_FORUM_COMMIT" ]]; then cd /opt/zeronet/ZeroTalk - git_pull $ZERONET_FORUM_COMMIT + git_pull $ZERONET_FORUM_REPO $ZERONET_FORUM_COMMIT sed -i "s/ZeroNet Forum commit.*/ZeroNet Forum commit:$ZERONET_FORUM_COMMIT/g" $COMPLETION_FILE fi else @@ -2674,7 +2679,7 @@ function install_zeronet { CURRENT_ZERONET_COMMIT=$(grep "ZeroNet commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_ZERONET_COMMIT" != "$ZERONET_COMMIT" ]]; then cd /opt/zeronet - git_pull $ZERONET_COMMIT + git_pull $ZERONET_REPO $ZERONET_COMMIT sed -i "s/ZeroNet commit.*/ZeroNet commit:$ZERONET_COMMIT/g" $COMPLETION_FILE systemctl restart zeronet.service fi @@ -5280,7 +5285,7 @@ function encrypt_incoming_email { CURRENT_GPGIT_COMMIT=$(grep "gpgit commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_GPGIT_COMMIT" != "$GPGIT_COMMIT" ]]; then cd $INSTALL_DIR/gpgit - git_pull $GPGIT_COMMIT + git_pull $GPGIT_REPO $GPGIT_COMMIT sed -i "s/gpgit commit.*/gpgit commit:$GPGIT_COMMIT/g" $COMPLETION_FILE cp gpgit.pl /usr/bin/gpgit.pl fi @@ -5592,7 +5597,7 @@ function email_archiving { CURRENT_CLEANUP_MAILDIR_COMMIT=$(grep "cleanup-maildir commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_CLEANUP_MAILDIR_COMMIT" != "$CLEANUP_MAILDIR_COMMIT" ]]; then cd $INSTALL_DIR/cleanup-maildir - git_pull $CLEANUP_MAILDIR_COMMIT + git_pull $CLEANUP_MAILDIR_REPO $CLEANUP_MAILDIR_COMMIT sed -i "s/cleanup-maildir commit.*/cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT/g" $COMPLETION_FILE cp $INSTALL_DIR/cleanup-maildir/cleanup-maildir /usr/bin fi @@ -5878,7 +5883,7 @@ function install_web_server { CURRENT_NGINX_ENSITE_COMMIT=$(grep "Nginx-ensite commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_NGINX_ENSITE_COMMIT" != "$NGINX_ENSITE_COMMIT" ]]; then $INSTALL_DIR/nginx_ensite - git_pull $NGINX_ENSITE_COMMIT + git_pull $NGINX_ENSITE_REPO $NGINX_ENSITE_COMMIT sed -i "s/Nginx-ensite commit.*/Nginx-ensite commit:$NGINX_ENSITE_COMMIT/g" $COMPLETION_FILE make install fi @@ -6144,7 +6149,7 @@ function install_owncloud_music_app { CURRENT_OWNCLOUD_MUSIC_APP_COMMIT=$(grep "Owncloud music app commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$OWNCLOUD_MUSIC_APP_COMMIT" != "$OWNCLOUD_MUSIC_APP_COMMIT" ]]; then cd /usr/share/owncloud/apps/music - git_pull $OWNCLOUD_MUSIC_APP_COMMIT + git_pull $OWNCLOUD_MUSIC_APP_REPO $OWNCLOUD_MUSIC_APP_COMMIT sed -i "s/Owncloud music app commit.*/Owncloud music app commit:$OWNCLOUD_MUSIC_APP_COMMIT/g" $COMPLETION_FILE fi else @@ -6606,7 +6611,7 @@ function install_gogs { CURRENT_GOGS_COMMIT=$(grep "Gogs commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_GOGS_COMMIT" != "$GOGS_COMMIT" ]]; then cd $GOPATH/src/github.com/gogits/gogs - git_pull $GOGS_COMMIT + git_pull $GIT_DOMAIN_REPO $GOGS_COMMIT sed -i "s/Gogs commit.*/Gogs commit:$GOGS_COMMIT/g" $COMPLETION_FILE go get -u ./... if [ ! "$?" = "0" ]; then @@ -6941,7 +6946,7 @@ function install_tox_node { CURRENT_TOX_COMMIT=$(grep "toxcore commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_TOX_COMMIT" != "$TOX_COMMIT" ]]; then cd $INSTALL_DIR/toxcore - git_pull $TOX_COMMIT + git_pull $TOX_REPO $TOX_COMMIT sed -i "s/toxcore commit.*/toxcore commit:$TOX_COMMIT/g" $COMPLETION_FILE autoreconf -i ./configure --enable-daemon @@ -7107,7 +7112,7 @@ function install_tox_client { CURRENT_TOXIC_COMMIT=$(grep "Toxic commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_TOXIC_COMMIT" != "$TOXIC_COMMIT" ]]; then cd $INSTALL_DIR/toxic - git_pull $TOXIC_COMMIT + git_pull $TOXIC_REPO $TOXIC_COMMIT sed -i "s/Toxic commit.*/Toxic commit:$TOXIC_COMMIT/g" $COMPLETION_FILE make make install @@ -7848,7 +7853,7 @@ function install_blog { CURRENT_FULLBLOG_COMMIT=$(grep "Blog commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_FULLBLOG_COMMIT" != "$FULLBLOG_COMMIT" ]]; then cd /var/www/$FULLBLOG_DOMAIN_NAME/htdocs - git_pull $FULLBLOG_COMMIT + git_pull $FULLBLOG_REPO $FULLBLOG_COMMIT sed -i "s/Blog commit.*/Blog commit:$FULLBLOG_COMMIT/g" $COMPLETION_FILE chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs fi @@ -8225,7 +8230,7 @@ function install_gnu_social { CURRENT_GNUSOCIAL_COMMIT=$(grep "GNU Social commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_GNUSOCIAL_COMMIT" != "$GNUSOCIAL_COMMIT" ]]; then cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs - git_pull $GNUSOCIAL_COMMIT + git_pull $MICROBLOG_REPO $GNUSOCIAL_COMMIT sed -i "s/GNU Social commit.*/GNU Social commit:$GNUSOCIAL_COMMIT/g" $COMPLETION_FILE chown -R www-data:www-data /var/www/$MICROBLOG_DOMAIN_NAME/htdocs fi @@ -8590,7 +8595,7 @@ function install_hubzilla { CURRENT_HUBZILLA_COMMIT=$(grep "Hubzilla commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_HUBZILLA_COMMIT" != "$HUBZILLA_COMMIT" ]]; then cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs - git_pull $HUBZILLA_COMMIT + git_pull $HUBZILLA_REPO $HUBZILLA_COMMIT sed -i "s/Hubzilla commit.*/Hubzilla commit:$HUBZILLA_COMMIT/g" $COMPLETION_FILE chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs fi @@ -8601,7 +8606,7 @@ function install_hubzilla { CURRENT_HUBZILLA_ADDONS_COMMIT=$(grep "Hubzilla addons commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_HUBZILLA_ADDONS_COMMIT" != "$HUBZILLA_ADDONS_COMMIT" ]]; then cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/addon - git_pull $HUBZILLA_ADDONS_COMMIT + git_pull $HUBZILLA_ADDONS_REPO $HUBZILLA_ADDONS_COMMIT sed -i "s/Hubzilla addons commit.*/Hubzilla addons commit:$HUBZILLA_ADDONS_COMMIT/g" $COMPLETION_FILE chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs fi @@ -9446,7 +9451,7 @@ function install_dynamicdns { CURRENT_INADYN_COMMIT=$(grep "inadyn commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_INADYN_COMMIT" != "$INADYN_COMMIT" ]]; then cd $INSTALL_DIR/inadyn - git_pull $INADYN_COMMIT + git_pull $INADYN_REPO $INADYN_COMMIT sed -i "s/inadyn commit.*/inadyn commit:$INADYN_COMMIT/g" $COMPLETION_FILE ./configure USE_OPENSSL=1 make @@ -9560,7 +9565,7 @@ function install_ipfs { CURRENT_IPFS_COMMIT=$(grep "ipfs commit" $COMPLETION_FILE | awk -F ':' '{print $2}') if [[ "$CURRENT_IPFS_COMMIT" != "$IPFS_COMMIT" ]]; then cd /home/git/go/src/github.com/ipfs/go-ipfs - git_pull $IPFS_COMMIT + git_pull $IPFS_REPO $IPFS_COMMIT sed -i "s/ipfs commit.*/ipfs commit:$IPFS_COMMIT/g" $COMPLETION_FILE chown -R git:git /home/git systemctl restart ipfs diff --git a/src/freedombone-addcert b/src/freedombone-addcert index 4b48ceba..ea73da38 100755 --- a/src/freedombone-addcert +++ b/src/freedombone-addcert @@ -113,15 +113,20 @@ function git_clone { } function git_pull { + if [ ! $1 ]; then + echo $'git_pull no repo specified' + fi + git stash + git remote set-url origin $1 git checkout master if [ "${FRIENDS_TROVE_SERVER}" ]; then if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then if [ "$FRIENDS_TROVE_PASSWORD" ]; then if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then sshpass -p "$FRIENDS_TROVE_PASSWORD" git pull - if [ $1 ]; then - git checkout $1 -b $1 + if [ $2 ]; then + git checkout $2 -b $2 fi return fi @@ -130,8 +135,8 @@ function git_pull { fi git pull - if [ $1 ]; then - git checkout $1 -b $1 + if [ $2 ]; then + git checkout $2 -b $2 fi } @@ -274,7 +279,7 @@ function add_cert_letsencrypt { fi else cd ${INSTALL_DIR}/letsencrypt - git_pull + git_pull $LETSENCRYPT_REPO fi # stop the web server diff --git a/src/freedombone-upgrade b/src/freedombone-upgrade index dcdab573..59c43808 100755 --- a/src/freedombone-upgrade +++ b/src/freedombone-upgrade @@ -100,18 +100,31 @@ function git_clone { } function git_pull { + if [ ! $1 ]; then + echo $'git_pull no repo specified' + fi + git stash + git remote set-url origin $1 + git checkout master if [ "${FRIENDS_TROVE_SERVER}" ]; then if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then if [ "$FRIENDS_TROVE_PASSWORD" ]; then if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then sshpass -p "$FRIENDS_TROVE_PASSWORD" git pull + if [ $2 ]; then + git checkout $2 -b $2 + fi return fi fi fi fi git pull + + if [ $2 ]; then + git checkout $2 -b $2 + fi } if [ -f $CONFIGURATION_FILE ]; then @@ -132,7 +145,7 @@ fi if [ -d $PROJECT_DIR ]; then if [ -f $CONFIGURATION_FILE ]; then cd $PROJECT_DIR - git_pull + git_pull $PROJECT_REPO make install ${PROJECT_NAME} -c $CONFIGURATION_FILE fi