Skip to content

Commit fe746e2

Browse files
authored
Update CLI_owncloud_update.sh
1 parent ac19467 commit fe746e2

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

CLI_owncloud_update.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,28 @@ if [ -z "$targeturl" ] || [[ "$targeturl" = "q" ]] || [[ "$targeturl" = "Q" ]];
3434
then
3535
exit
3636
else
37-
3837
echo ""
3938
wget $targeturl -O $owncloud_dir/owncloud-latest.zip
39+
if [ $? -ne 0 ]; then
40+
echo ""
41+
echo "Error while fetching file."
42+
exit 1
43+
fi
44+
fi
45+
46+
read -p "Proceed update ? [Y/N]" -n 1 -r
47+
echo # (optional) move to a new line
48+
if [[ $REPLY =~ ^[Nn]$ ]]
49+
then
50+
exit 1
4051
fi
4152

4253
mv $owncloud_dir/owncloud $owncloud_dir/owncloud-bck
4354

4455
unzip $owncloud_dir/owncloud-latest.zip -d $owncloud_dir
4556

57+
rm $owncloud_dir/owncloud-latest.zip
58+
4659
cp $owncloud_dir/owncloud-bck/config/config.php $owncloud_dir/owncloud/config/config.php
4760
cp -r $owncloud_dir/owncloud-bck/data $owncloud_dir/owncloud/data
4861
chown -R www-data:www-data $owncloud_dir/owncloud
@@ -52,6 +65,10 @@ read -p "Is Owncloud successfully updated ? (I can wait...) [Y/N]" -n 1 -r
5265
echo # (optional) move to a new line
5366
if [[ $REPLY =~ ^[Yy]$ ]]
5467
then
55-
rm $owncloud_dir/owncloud-latest.zip
5668
rm -rf $owncloud_dir/owncloud-bck/
69+
else
70+
echo "Reverting to previous version."
71+
mv $owncloud_dir/owncloud/ $owncloud_dir/owncloud-update_pending/
72+
mv $owncloud_dir/owncloud-bck/ $owncloud_dir/owncloud/
73+
echo "Files are kept in $owncloud_dir/owncloud-update_pending/"
5774
fi

0 commit comments

Comments
 (0)