Skip to content

Commit

Permalink
simplify parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nacho committed Aug 10, 2017
1 parent ce90dea commit 52051bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions etc/nextcloudpi-config.d/letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

DOMAIN_=mycloud.ownyourbits.com
EMAIL_=mycloud@ownyourbits.com
NCDIR_=/var/www/nextcloud

NCDIR=/var/www/nextcloud
VHOSTCFG=/etc/apache2/sites-available/nextcloud.conf
VHOSTCFG2=/etc/apache2/sites-available/ncp.conf
DESCRIPTION="Automatic signed SSL certificates"
Expand Down Expand Up @@ -53,7 +54,7 @@ configure()
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_/fullchain.pem|" $VHOSTCFG2
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_/privkey.pem|" $VHOSTCFG2

/etc/letsencrypt/letsencrypt-auto certonly -n --no-self-upgrade --webroot -w $NCDIR_ --hsts --agree-tos -m $EMAIL_ -d $DOMAIN_ || return 1
/etc/letsencrypt/letsencrypt-auto certonly -n --no-self-upgrade --webroot -w $NCDIR --hsts --agree-tos -m $EMAIL_ -d $DOMAIN_ || return 1
echo "* 1 * * 1 root /etc/letsencrypt/certbot-auto renew --quiet" > /etc/cron.d/letsencrypt-ncp

cd /var/www/nextcloud
Expand Down
4 changes: 2 additions & 2 deletions etc/nextcloudpi-config.d/modsecurity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

ACTIVE_=no
NCDIR_=/var/www/nextcloud/
NCDIR=/var/www/nextcloud/
DESCRIPTION="Web Application Firewall for extra security (experimental)"

install()
Expand Down Expand Up @@ -77,7 +77,7 @@ a basic NextCloud installation. If a new App does not work disable it" \
configure()
{
cat > /etc/modsecurity/modsecurity_crs_99_whitelist.conf <<EOF
<Directory $NCDIR_>
<Directory $NCDIR>
# VIDEOS
SecRuleRemoveById 958291 # Range Header Checks
SecRuleRemoveById 981203 # Correlated Attack Attempt
Expand Down
18 changes: 9 additions & 9 deletions etc/nextcloudpi-config.d/nc-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


BACKUPFILE_=/media/USBdrive/nextcloud-bkp_xxxxxxxx.tar
BASEDIR_=/var/www
BASEDIR=/var/www
DBADMIN=ncadmin
DESCRIPTION="Restore a previously backuped NC instance"

Expand All @@ -39,9 +39,9 @@ You can use nc-backup " \

configure()
{
[ -f $BACKUPFILE_ ] || { echo -e "$BACKUPFILE_ not found"; return 1; }
[ -d $BASEDIR_ ] || { echo -e "$BASEDIR_ not found"; return 1; }
[ -d $BASEDIR_/nextcloud ] && { echo -e "WARNING: overwriting old instance"; }
[ -f $BACKUPFILE_ ] || { echo -e "$BACKUPFILE_ not found"; return 1; }
[ -d $BASEDIR ] || { echo -e "$BASEDIR not found"; return 1; }
[ -d $BASEDIR/nextcloud ] && { echo -e "WARNING: overwriting old instance"; }

local TMPDIR="$( dirname $BACKUPFILE_ )/$( basename ${BACKUPFILE_}-tmp )"
rm -rf "$TMPDIR" && mkdir -p "$TMPDIR"
Expand All @@ -50,8 +50,8 @@ configure()
## RESTORE FILES

echo -e "restore files..."
rm -rf $BASEDIR_/nextcloud
mv "$TMPDIR"/nextcloud $BASEDIR_
rm -rf $BASEDIR/nextcloud
mv "$TMPDIR"/nextcloud $BASEDIR

## RE-CREATE DATABASE TABLE

Expand All @@ -72,12 +72,12 @@ EOF

## RESTORE DATADIR

cd $BASEDIR_/nextcloud
cd $BASEDIR/nextcloud

# INCLUDEDATA=yes situation

if [[ $( ls "$TMPDIR" | wc -l ) == 2 ]]; then
local DATADIR=$( grep datadirectory $BASEDIR_/nextcloud/config/config.php | awk '{ print $3 }' | grep -oP "[^']*[^']" | head -1 )
local DATADIR=$( grep datadirectory $BASEDIR/nextcloud/config/config.php | awk '{ print $3 }' | grep -oP "[^']*[^']" | head -1 )
[[ "$DATADIR" == "" ]] && { echo -e "Error reading data directory"; return 1; }
echo -e "restore datadir to $DATADIR..."
rm -rf "$DATADIR"
Expand Down Expand Up @@ -107,7 +107,7 @@ EOF
rm -r "$TMPDIR"

# Just in case we moved the opcache dir
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$BASEDIR_/nextcloud/data/.opcache|" /etc/php/7.0/mods-available/opcache.ini
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$BASEDIR/nextcloud/data/.opcache|" /etc/php/7.0/mods-available/opcache.ini
}

install() { :; }
Expand Down

0 comments on commit 52051bb

Please sign in to comment.