Skip to content

Instantly share code, notes, and snippets.

@brantje
Last active August 29, 2015 14:19
Show Gist options
  • Save brantje/403f8f711167f85a5f14 to your computer and use it in GitHub Desktop.
Save brantje/403f8f711167f85a5f14 to your computer and use it in GitHub Desktop.
Owncloud update & update apps
#!/bin/bash
BRANCH="stable8"
ROOTDIR="$PWD"
WWWUSER="www-data"
WWWGROUP="www-data"
if [ $(id -u) != 0 ]; then
printf "**************************************\n"
printf "* Error: You must run this with sudo. *\n"
printf "**************************************\n"
exit 0
fi
git checkout $BRANCH -q > /dev/null
echo "Checking if owncloud needs updating"
OCUPDATE=$(git pull origin $BRANCH -q);
if [ "$OCUPDATE" = "Already up-to-date." ]; then
echo "Already up-to-date"
else
COLOR="green"
green='\033[0;32m'
NC='\033[0m' # No Color
echo -e "${green}ownCloud has been updated!${NC}"
echo "Owncloud has been updated!"
fi;
git submodule update > /dev/null
for d in apps/*/ ; do
GITDIR="$ROOTDIR/$d"
cd "$GITDIR"
BRANCHES=$(git branch -a -q);
if test "${BRANCHES#*$BRANCH}" != "$BRANCHES"
then
TARGETBRANCH=$BRANCH
else
TARGETBRANCH="master"
fi;
echo "Updating $d branch: $TARGETBRANCH"
git checkout $TARGETBRANCH -q > /dev/null
GITRESULT=$(git pull origin $TARGETBRANCH -q)
if [ "$GITRESULT" = "Already up-to-date." ]; then
echo -e "Already up-to-date"
else
COLOR="green"
green='\033[0;32m'
NC='\033[0m' # No Color
echo -e "${green}App has been updated${NC}"
fi;
echo "============="
done
echo "Running occ upgrade"
sudo -u $WWWUSER $ROOTDIR/occ upgrade
#custom things:
echo "Enable passman"
sudo -u $WWWUSER $ROOTDIR/occ app:enable passman
echo "Correcting permissions"
chown -R $WWWUSER:$WWWGROUP $ROOTDIR
find $ROOTDIR -type d -exec chmod u=rwx,g=rx,o= '{}' \;
find $ROOTDIR -type f -exec chmod u=rw,g=r,o= '{}' \;
chmod +x $ROOTDIR/update-owncloud.sh
chmod +x $ROOTDIR/occ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment