Move commit function to separate script

This commit is contained in:
Bob Mottram 2016-06-30 16:04:55 +01:00
parent 78f200db88
commit 229df46f2a
No known key found for this signature in database
GPG Key ID: BA68F26108DC9F87
2 changed files with 114 additions and 94 deletions

View File

@ -1578,100 +1578,6 @@ function rss_reader_modifications {
chmod a+x $RSS_READER_PATH
}
function set_repo_commit {
repo_dir=$1
repo_commit_name=$2
repo_commit=$3
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 [[ $repo_dir == *"www"* ]]; then
chown -R www-data:www-data $repo_dir
fi
if [[ $repo_dir == *"cjdns" ]]; then
./do
fi
if [[ $repo_dir == *"tlsdate" ]]; then
cd $INSTALL_DIR/tlsdate
make clean
./configure
if [ ! "$?" = "0" ]; then
echo $'Failed to configure tlsdate'
exit 727824
fi
make
if [ ! "$?" = "0" ]; then
echo $'Failed to build tlsdate'
exit 728752
fi
make install
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
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
fi
else
echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
fi
fi
}
function wait_for_onion_service {
onion_service_name="$1"

View File

@ -88,4 +88,118 @@ function git_pull {
fi
}
# This might be replaced in future with a separate rss reader script
function rss_reader_modifications {
# modify the rss reader to use a socks5 proxy rather than a http proxy
if [ ! -d $RSS_READER_PATH ]; then
return
fi
# ensure that socks5 proxy is used
if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/plugins/af_unburn/init.php; then
sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/plugins/af_unburn/init.php
fi
if ! grep -q "CURLOPT_PROXYTYPE" $RSS_READER_PATH/include/functions.php; then
sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/include/functions.php
fi
chown -R www-data:www-data $RSS_READER_PATH
chmod a+x $RSS_READER_PATH
}
# This ensures that a given repo is on a given commit
# If it isn't then it attempts to upgrade
function set_repo_commit {
repo_dir=$1
repo_commit_name=$2
repo_commit=$3
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 [[ $repo_dir == *"www"* ]]; then
chown -R www-data:www-data $repo_dir
fi
if [[ $repo_dir == *"cjdns" ]]; then
./do
fi
if [[ $repo_dir == *"tlsdate" ]]; then
cd $INSTALL_DIR/tlsdate
make clean
./configure
if [ ! "$?" = "0" ]; then
echo $'Failed to configure tlsdate'
exit 727824
fi
make
if [ ! "$?" = "0" ]; then
echo $'Failed to build tlsdate'
exit 728752
fi
make install
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
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
fi
else
echo "${repo_commit_name}:${repo_commit}" >> $COMPLETION_FILE
fi
fi
}
# NOTE: deliberately no exit 0