slackbuilds/n/nextcloud/nextcloud.SlackBuild
2017-02-20 14:59:31 +01:00

101 lines
2.8 KiB
Bash
Executable file

#!/bin/sh
CWD=$(pwd)
PRGNAM=$(basename $CWD)
VERSION=${VERSION:-11.0.1}
ARCH="noarch" # hardcode ARCH
BUILD=${BUILD:-1}
TAG=${TAG:-cyco}
VHOST=${VHOST:-vhosts/$PRGNAM/}
VHOSTROOT=/var/www/${VHOST}
DOCROOT=${DOCROOT:-/var/www/${VHOST}htdocs}
PHPUSER=${PHPUSER:-apache}
PHPGROUP=${PHPGROUP:-apache}
TMP=${TMP:-/tmp/$TAG}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
ACTIVE_APPS="audioplayer calendar contacts deck direct_menu gallery ocsms"
set -eu
rm -rf $PKG
mkdir -p $TMP $OUTPUT $PKG/$VHOSTROOT
if [ "x$1" == "x--git" ]; then
REPOSITORY=/home/installs/SlackBuilds/repositories/$PRGNAM
[ ! -e $REPOSITORY ] && git clone https://github.com/nextcloud/server $REPOSITORY
( cd $REPOSITORY
git pull
git submodule init
git submodule update )
VERSION="$( cd $REPOSITORY && git log -1 --format=%h_%ad --date=format:%Y.%m.%d )"
cp -R $REPOSITORY $PKG/$VHOSTROOT/htdocs
rm -fr $PKG/$VHOSTROOT/htdocs/.git
else if [ "x$1" == "x--daily" ]; then
VERSION="daily_$(date +%F | tr - .)"
wget -c https://download.nextcloud.com/server/daily/latest.tar.bz2 -O $CWD/$PRGNAM-$VERSION.tar.bz2
else
[ ! -e $CWD/$PRGNAM-$VERSION.tar.bz2 ] && wget -c https://download.nextcloud.com/server/releases/$PRGNAM-$VERSION.tar.bz2 -O $CWD/$PRGNAM-$VERSION.tar.bz2
fi
cd $PKG/$VHOSTROOT
tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2
mv $PRGNAM htdocs
fi
cd $PKG/$VHOSTROOT/htdocs
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 -o -perm 755 \) \
-exec chmod 750 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 -o -perm 644 \) \
-exec chmod 640 {} \;
mkdir -p $PKG/usr/doc/$PRGNAM
for i in AUTHORS CONTRIBUTING.md COPYING* README*; do
[ -e $i ] && cp -a $i $PKG/usr/doc/$PRGNAM
done
# Change ownership and perms and create a link.
chown -R $PHPUSER:$PHPGROUP $PKG/$DOCROOT
chmod 0750 $PKG/$DOCROOT
chmod 0770 $PKG/$DOCROOT/{config,apps}
mkdir -p $PKG/install
cat <<EOF > $PKG/install/doinst.sh
#!/bin/sh
chown -R $PHPUSER:$PHPGROUP $DOCROOT/apps
grep -q "/var/www/${VHOST}htdocs/cron.php" /var/spool/cron/crontabs/apache || echo "*/15 * * * * php -f /var/www/${VHOST}htdocs/cron.php" >> /var/spool/cron/crontabs/apache
echo "Upgrading database and applications"
( cd /var/www/${VHOST}htdocs/
sudo -u $PHPUSER php ./occ upgrade
for a in $ACTIVE_APPS; do
sudo -u $PHPUSER php ./occ app:enable \$a
done
)
echo "Post-installation process completed"
EOF
cat <<EOF > $PKG/install/slack-desc
$PRGNAM: $PRGNAM (self-hosted cloud platform)
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: http://nextcloud.org
$PRGNAM:
EOF
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}