2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2016-07-02 12:42:13 +02:00
|
|
|
|
|
|
|
CWD=$(pwd)
|
|
|
|
|
|
|
|
PRGNAM=$(basename $CWD)
|
2019-06-24 14:18:08 +02:00
|
|
|
RELEASE_TYPE=${RELEASE_TYPE:-releases}
|
2017-11-06 12:20:58 +01:00
|
|
|
VERSION=${VERSION:-stable}
|
2016-07-02 12:42:13 +02:00
|
|
|
ARCH="noarch" # hardcode ARCH
|
|
|
|
BUILD=${BUILD:-1}
|
2020-06-25 11:23:11 +02:00
|
|
|
TAG=${TAG:-gwh}
|
2016-07-02 12:42:13 +02:00
|
|
|
|
2021-09-22 10:29:15 +02:00
|
|
|
VHOST=${VHOST:-vhosts/$PRGNAM}
|
2016-07-19 16:31:35 +02:00
|
|
|
VHOSTROOT=/var/www/${VHOST}
|
2021-09-22 10:29:15 +02:00
|
|
|
DOCROOT=${DOCROOT:-/var/www/${VHOST}/htdocs}
|
2017-11-08 15:04:27 +01:00
|
|
|
DATAROOT=${DATAROOT:-/home/nextcloud/data}
|
2016-07-02 12:42:13 +02:00
|
|
|
|
|
|
|
PHPUSER=${PHPUSER:-apache}
|
|
|
|
PHPGROUP=${PHPGROUP:-apache}
|
|
|
|
|
|
|
|
TMP=${TMP:-/tmp/$TAG}
|
|
|
|
PKG=$TMP/package-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
rm -rf $PKG
|
2016-07-19 16:31:35 +02:00
|
|
|
mkdir -p $TMP $OUTPUT $PKG/$VHOSTROOT
|
2016-07-02 12:42:13 +02:00
|
|
|
|
2017-11-06 12:20:58 +01:00
|
|
|
case $VERSION in
|
|
|
|
"stable")
|
2019-06-24 14:18:08 +02:00
|
|
|
wget -c https://download.nextcloud.com/server/${RELEASE_TYPE}/latest.tar.bz2 -O $CWD/nextcloud.tar.bz2
|
2017-12-15 10:18:14 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"master")
|
|
|
|
wget -c https://download.nextcloud.com/server/daily/latest-master.tar.bz2 -O $CWD/nextcloud.tar.bz2
|
2017-11-06 12:17:11 +01:00
|
|
|
;;
|
2017-05-23 11:16:12 +02:00
|
|
|
|
|
|
|
*)
|
2019-06-24 14:18:08 +02:00
|
|
|
[ ! -e $CWD/nextcloud-$VERSION.tar.bz2 ] && wget -c https://download.nextcloud.com/server/${RELEASE_TYPE}/nextcloud-$VERSION.tar.bz2 -O $CWD/nextcloud.tar.bz2
|
2017-11-06 12:17:11 +01:00
|
|
|
;;
|
2017-05-23 11:16:12 +02:00
|
|
|
esac
|
2016-07-19 16:31:35 +02:00
|
|
|
|
2017-12-15 10:18:14 +01:00
|
|
|
cd $PKG/$VHOSTROOT
|
|
|
|
tar xvf $CWD/nextcloud.tar.bz2
|
|
|
|
rm $CWD/nextcloud.tar.bz2
|
|
|
|
mv nextcloud htdocs
|
|
|
|
VERSION=$(grep "Version =" htdocs/version.php | grep -o "[0-9,]*" | tr , .)
|
|
|
|
|
2018-03-14 14:35:32 +01:00
|
|
|
cp $CWD/nextcloud-news-updater.rb .
|
|
|
|
chmod +x nextcloud-news-updater.rb
|
|
|
|
|
2016-08-25 17:45:30 +02:00
|
|
|
cd $PKG/$VHOSTROOT/htdocs
|
2016-07-02 12:42:13 +02:00
|
|
|
chown -R root:root .
|
|
|
|
find . \
|
2016-09-18 22:28:40 +02:00
|
|
|
\( -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 {} \;
|
2016-07-02 12:42:13 +02:00
|
|
|
|
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM
|
2017-02-20 14:59:26 +01:00
|
|
|
for i in AUTHORS CONTRIBUTING.md COPYING* README*; do
|
|
|
|
[ -e $i ] && cp -a $i $PKG/usr/doc/$PRGNAM
|
|
|
|
done
|
2016-07-02 12:42:13 +02:00
|
|
|
|
|
|
|
# Change ownership and perms and create a link.
|
2016-07-19 16:31:35 +02:00
|
|
|
chown -R $PHPUSER:$PHPGROUP $PKG/$DOCROOT
|
|
|
|
chmod 0750 $PKG/$DOCROOT
|
|
|
|
chmod 0770 $PKG/$DOCROOT/{config,apps}
|
2016-07-02 12:42:13 +02:00
|
|
|
|
2017-11-08 15:04:27 +01:00
|
|
|
mkdir -p $PKG/etc/logrotate.d/
|
|
|
|
cat <<EOF > $PKG/etc/logrotate.d/nextcloud.new
|
|
|
|
$DATAROOT/nextcloud.log {
|
|
|
|
monthly
|
|
|
|
rotate 6
|
|
|
|
delaycompress
|
|
|
|
compress
|
|
|
|
notifempty
|
|
|
|
missingok
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2016-07-02 12:42:13 +02:00
|
|
|
mkdir -p $PKG/install
|
|
|
|
cat <<EOF > $PKG/install/doinst.sh
|
2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2017-11-08 15:04:27 +01:00
|
|
|
config() {
|
|
|
|
NEW="\$1"
|
|
|
|
OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
|
|
|
|
# If there's no config file by that name, mv it over:
|
|
|
|
if [ ! -r \$OLD ]; then
|
|
|
|
mv \$NEW \$OLD
|
|
|
|
elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then
|
|
|
|
# toss the redundant copy
|
|
|
|
rm \$NEW
|
|
|
|
fi
|
|
|
|
# Otherwise, we leave the .new copy for the admin to consider...
|
|
|
|
}
|
|
|
|
|
|
|
|
config etc/logrotate.d/nextcloud.new
|
|
|
|
|
2016-07-19 16:31:35 +02:00
|
|
|
chown -R $PHPUSER:$PHPGROUP $DOCROOT/apps
|
2016-07-02 12:42:13 +02:00
|
|
|
|
2021-09-22 10:29:15 +02:00
|
|
|
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
|
|
|
|
grep -q "/var/www/${VHOST}/nextcloud-news-updater.rb" /var/spool/cron/crontabs/apache || echo "*/15 * * * * php -f /var/www/${VHOST}/nextcloud-news-updater.rb" >> /var/spool/cron/crontabs/apache
|
2016-07-02 12:42:13 +02:00
|
|
|
|
|
|
|
echo "Upgrading database and applications"
|
2021-09-22 10:29:15 +02:00
|
|
|
( cd /var/www/${VHOST}/htdocs/
|
2018-10-15 07:15:57 +02:00
|
|
|
sudo -u $PHPUSER php ./occ upgrade --quiet --no-interaction
|
2016-07-02 12:42:13 +02:00
|
|
|
)
|
|
|
|
echo "Post-installation process completed"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF > $PKG/install/slack-desc
|
|
|
|
$PRGNAM: $PRGNAM (self-hosted cloud platform)
|
|
|
|
$PRGNAM:
|
2016-09-18 22:28:40 +02:00
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM:
|
2016-07-02 12:42:13 +02:00
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: http://nextcloud.org
|
|
|
|
$PRGNAM:
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cd $PKG
|
2018-04-20 23:02:35 +02:00
|
|
|
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
|
2023-08-16 12:23:26 +02:00
|
|
|
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}
|