aboutsummaryrefslogtreecommitdiff
path: root/nextcloud-dl
blob: 94cb9315a8db3c6fc61622ead1c5bea9811a37bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#
# Nextcloud software upgrader.
# See https://docs.nextcloud.com/server/16/admin_manual/maintenance/upgrade.html
#

# Config parameters
BASENAME="`basename $0`"
OLD_VERSION="$1"
VERSION="$2"

# Syntax check
if [ -z "$2" ]; then
  echo "usage: $BASENAME <old-version> <new-version>"
  exit 1
fi

# Check installed versions
if [ ! -d "nextcloud-$OLD_VERSION" ]; then
  echo "error: nextcloud-$OLD_VERSION is not installed, aborting."
  exit 1
elif [ -d "nextcloud-$VERSION" ]; then
  echo "error: nextcloud-$VERSION already installed, aborting."
  exit 1
fi

# Download package
wget -c https://download.nextcloud.com/server/releases/nextcloud-$VERSION.tar.bz2 || exit 1
wget -c https://download.nextcloud.com/server/releases/nextcloud-$VERSION.tar.bz2.sha256 || exit 1
sha256sum -c nextcloud-$VERSION.tar.bz2.sha256 || exit -1

# Decompress
(
  mkdir tmp
  cd tmp
  tar xvf ../nextcloud-$VERSION.tar.bz2
  mv nextcloud ../nextcloud-$VERSION
  cd ..
  rmdir tmp
)

# Remove package
rm nextcloud-$VERSION.tar.bz2

# Sync configuration and data
chown -R root. nextcloud-$VERSION
rsync -av nextcloud-$OLD_VERSION/config/ nextcloud-$VERSION/config/
rsync -av nextcloud-$OLD_VERSION/data/ nextcloud-$VERSION/data/

# Symlink to contrib content
#(
#  cd nextcloud-$VERSION
#  ln -s ../contrib
#  rm -rf themes
#  ln -s contrib/themes
#)

# Pivot
rm nextcloud && ln -s nextcloud-$VERSION nextcloud

# Audit
echo "Audit:" && \
du -hs nextcloud-$OLD_VERSION && \
du -hs nextcloud-$VERSION

# Finish
echo "Please fix config.php manually."