mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-09 14:42:01 -03:30
ncurses configuration
This commit is contained in:
parent
88c3a60135
commit
eec41a1ef5
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.*.swp
|
||||
22
fail2ban.sh
22
fail2ban.sh
@ -19,10 +19,10 @@ set -xe
|
||||
|
||||
sudo su
|
||||
|
||||
NCLOG=/var/www/nextcloud/data/nextcloud.log # location of Nextcloud logs
|
||||
BANTIME=600 # time to ban an IP that exceeded attempts
|
||||
FINDTIME=600 # cooldown time for incorrect passwords
|
||||
MAXRETRY=6 # bad attempts before banning an IP
|
||||
NCLOG_=/var/www/nextcloud/data/nextcloud.log # location of Nextcloud logs
|
||||
BANTIME_=600 # time to ban an IP that exceeded attempts
|
||||
FINDTIME_=600 # cooldown time for incorrect passwords
|
||||
MAXRETRY_=6 # bad attempts before banning an IP
|
||||
|
||||
set -xe
|
||||
|
||||
@ -39,7 +39,7 @@ chown -R www-data /var/www/nextcloud/data
|
||||
cd /var/www/nextcloud
|
||||
sudo -u www-data php occ config:system:set loglevel --value=2
|
||||
sudo -u www-data php occ config:system:set log_type --value=file
|
||||
sudo -u www-data php occ config:system:set logfile --value=$NCLOG
|
||||
sudo -u www-data php occ config:system:set logfile --value=$NCLOG_
|
||||
|
||||
cat > /etc/fail2ban/filter.d/nextcloud.conf <<'EOF'
|
||||
[INCLUDES]
|
||||
@ -62,12 +62,12 @@ cat > /etc/fail2ban/jail.conf <<EOF
|
||||
ignoreip = 127.0.0.1/8
|
||||
|
||||
# "bantime" is the number of seconds that a host is banned.
|
||||
bantime = $BANTIME
|
||||
bantime = $BANTIME_
|
||||
|
||||
# A host is banned if it has generated "maxretry" during the last "findtime"
|
||||
# seconds.
|
||||
findtime = $FINDTIME
|
||||
maxretry = $MAXRETRY
|
||||
findtime = $FINDTIME_
|
||||
maxretry = $MAXRETRY_
|
||||
|
||||
#
|
||||
# ACTIONS
|
||||
@ -90,7 +90,7 @@ enabled = true
|
||||
port = ssh
|
||||
filter = sshd
|
||||
logpath = /var/log/auth.log
|
||||
maxretry = $MAXRETRY
|
||||
maxretry = $MAXRETRY_
|
||||
|
||||
#
|
||||
# HTTP servers
|
||||
@ -101,8 +101,8 @@ maxretry = $MAXRETRY
|
||||
enabled = true
|
||||
port = http,https
|
||||
filter = nextcloud
|
||||
logpath = $NCLOG
|
||||
maxretry = $MAXRETRY
|
||||
logpath = $NCLOG_
|
||||
maxretry = $MAXRETRY_
|
||||
EOF
|
||||
|
||||
# CLEANUP
|
||||
|
||||
16
installer.sh
16
installer.sh
@ -1,17 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO
|
||||
# Nextcloud installation on QEMU emulated Raspbian image
|
||||
# config from the beginning and store it in a variable?
|
||||
# install to real rpi without QEMU
|
||||
# no dialog (automatic) version
|
||||
|
||||
|
||||
|
||||
# Generic software installer on QEMU emulated Raspbian image
|
||||
# Tested with 2017-01-11-raspbian-jessie.img (and lite)
|
||||
#
|
||||
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
|
||||
# GPL licensed (see end of file) * Use at your own risk!
|
||||
#
|
||||
# Usage:
|
||||
# ./install-nextcloud.sh <IP> # Use the IP of your running QEMU Raspbian image
|
||||
# ./installer.sh <script.sh> <imgfile.img> <IP>
|
||||
#
|
||||
# Notes:
|
||||
# Set DOWNLOAD=0 if you have already downloaded an image. Rename it to nextcloudpi.img
|
||||
# Use a Raspbian image to be run on QEMU
|
||||
# Use any script that would run locally on the image
|
||||
# Use the IP of your running QEMU Raspbian image (DHCP should assign always the same)
|
||||
|
||||
INSTALL_SCRIPT=$1
|
||||
IMGFILE=$2 # First argument is the image file to start from
|
||||
@ -20,7 +28,7 @@ IP=$3 # Second argument is the QEMU Raspbian IP address
|
||||
source library.sh # initializes $IMGOUT
|
||||
|
||||
launch_install_qemu $INSTALL_SCRIPT $IMGFILE $IP || exit
|
||||
pack_image $IMGFILE $IMGOUT
|
||||
pack_image $IMGFILE $IMGOUT
|
||||
|
||||
|
||||
# License
|
||||
|
||||
108
library.sh
108
library.sh
@ -7,8 +7,9 @@
|
||||
|
||||
|
||||
IMGOUT=$( basename $IMGFILE .img )_$( basename $INSTALL_SCRIPT .sh ).img
|
||||
CFGOUT=config_$( basename $INSTALL_SCRIPT .sh ).txt
|
||||
|
||||
SSH=( ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=5 -o ConnectTimeout=1 -o LogLevel=quiet )
|
||||
SSH=( ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=5 -o ConnectTimeout=20 -o LogLevel=quiet )
|
||||
|
||||
function launch_install_qemu()
|
||||
{
|
||||
@ -31,8 +32,8 @@ function launch_install_qemu()
|
||||
launch_qemu $IMGFILE &
|
||||
sleep 10
|
||||
wait_SSH $IP
|
||||
sleep 120 # FIXME for some reason, SSH is ready but blocks for PIXEL image
|
||||
launch_installation $INSTALL_SCRIPT
|
||||
sleep 120 # FIXME for some reason, SSH is ready but fails if CPU still busy
|
||||
launch_installation $INSTALL_SCRIPT $IP
|
||||
wait
|
||||
NUM_REBOOTS=$(( NUM_REBOOTS-1 ))
|
||||
done
|
||||
@ -63,9 +64,108 @@ function wait_SSH()
|
||||
function launch_installation()
|
||||
{
|
||||
local INSTALL_SCRIPT=$1
|
||||
local IP=$2
|
||||
test -f $1 || { echo "File $INSTALL_SCRIPT not found"; return 1; }
|
||||
echo "Launching installation"
|
||||
cat $INSTALL_SCRIPT | sshpass -praspberry ${SSH[@]} pi@$IP
|
||||
config $INSTALL_SCRIPT 4>&1 1>&2 2>&4 4>&- | sshpass -praspberry ${SSH[@]} pi@$IP | sed 1,7d
|
||||
echo "configuration saved to $CFGOUT"
|
||||
}
|
||||
|
||||
function config()
|
||||
{
|
||||
local INSTALL_SCRIPT="$1"
|
||||
local BACKTITLE="NextCloudPi installer configuration"
|
||||
|
||||
test -f "$INSTALL_SCRIPT" || { echo "file "$INSTALL_SCRIPT" not found"; return 1; }
|
||||
local VARS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | cut -d= -f1 | sed 's|_$||' ) )
|
||||
local VALS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | cut -d= -f2 ) )
|
||||
|
||||
test ${#VARS[@]} -eq 0 && { echo here; cat "$INSTALL_SCRIPT" >&2; return; }
|
||||
|
||||
for i in `seq 1 1 ${#VARS[@]} `; do
|
||||
local PARAM+="${VARS[$((i-1))]} $i 1 ${VALS[$((i-1))]} $i 15 30 0 "
|
||||
done
|
||||
|
||||
local DIALOG_OK=0
|
||||
local DIALOG_CANCEL=1
|
||||
local DIALOG_HELP=2
|
||||
local DIALOG_EXTRA=3
|
||||
local DIALOG_ITEM_HELP=4
|
||||
local DIALOG_ERROR=254
|
||||
local DIALOG_ESC=255
|
||||
local returncode=0
|
||||
|
||||
while test $returncode != 1 && test $returncode != 250; do
|
||||
exec 3>&1
|
||||
local value
|
||||
value=$( dialog --ok-label "Submit" \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--form "Enter the desired configuration" \
|
||||
20 50 0 $PARAM \
|
||||
2>&1 1>&3 )
|
||||
returncode=$?
|
||||
exec 3>&-
|
||||
|
||||
case $returncode in
|
||||
$DIALOG_CANCEL)
|
||||
dialog \
|
||||
--clear \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--yesno "Really quit?" 10 30
|
||||
case $? in
|
||||
$DIALOG_OK)
|
||||
break
|
||||
;;
|
||||
$DIALOG_CANCEL)
|
||||
returncode=99
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
$DIALOG_OK)
|
||||
dialog \
|
||||
--clear \
|
||||
--backtitle "$BACKTITLE" --no-collapse --cr-wrap \
|
||||
--yesno "The following configuration will be used\n\n$value" 10 60
|
||||
case $? in
|
||||
$DIALOG_OK)
|
||||
local RET=( $value )
|
||||
for i in `seq 0 1 $(( ${#RET[@]} - 1 )) `; do
|
||||
local SEDRULE+="s|^${VARS[$i]}_=.*|${VARS[$i]}_=${RET[$i]}|;"
|
||||
local CONFIG+="${VARS[$i]}=${RET[$i]}\n"
|
||||
done
|
||||
break
|
||||
;;
|
||||
$DIALOG_CANCEL)
|
||||
returncode=99
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
$DIALOG_HELP)
|
||||
echo "Button 2 (Help) pressed."
|
||||
return
|
||||
;;
|
||||
$DIALOG_EXTRA)
|
||||
echo "Button 3 (Extra) pressed."
|
||||
return
|
||||
;;
|
||||
$DIALOG_ERROR)
|
||||
echo "ERROR!$value"
|
||||
return
|
||||
;;
|
||||
$DIALOG_ESC)
|
||||
echo "ESC pressed."
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo "Return code was $returncode"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
sed $SEDRULE "$INSTALL_SCRIPT" >&2
|
||||
echo -e "$CONFIG" > $CFGOUT
|
||||
clear
|
||||
}
|
||||
|
||||
function pack_image()
|
||||
|
||||
30
nextcloud.sh
30
nextcloud.sh
@ -23,10 +23,10 @@ set -xe
|
||||
sudo su
|
||||
|
||||
VER=11.0.1
|
||||
ADMINUSER=admin
|
||||
DBADMIN=ncadmin
|
||||
DBPASSWD=ownyourbits
|
||||
MAX_FILESIZE=1G
|
||||
ADMINUSER_=admin
|
||||
DBADMIN_=ncadmin
|
||||
DBPASSWD_=ownyourbits
|
||||
MAX_FILESIZE_=1G
|
||||
STATE_FILE=/home/pi/.installation_state
|
||||
|
||||
set -xe
|
||||
@ -79,8 +79,8 @@ EOF
|
||||
apt-get install php7.0-APC -y
|
||||
apt-get install libxml2-dev php-zip php-dom php-xmlwriter php-xmlreader php-gd php-curl php-mbstring -y
|
||||
|
||||
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password password $DBPASSWD"
|
||||
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password_again password $DBPASSWD"
|
||||
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password password $DBPASSWD_"
|
||||
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password_again password $DBPASSWD_"
|
||||
apt-get install mariadb-server php7.0-mysql -y
|
||||
|
||||
# CONFIGURE APACHE AND PHP7
|
||||
@ -212,10 +212,10 @@ cat > /etc/apache2/sites-available/nextcloud.conf <<'EOF'
|
||||
EOF
|
||||
a2ensite nextcloud
|
||||
|
||||
mysql -u root -p$DBPASSWD <<EOF
|
||||
mysql -u root -p$DBPASSWD_ <<EOF
|
||||
CREATE DATABASE nextcloud;
|
||||
CREATE USER '$DBADMIN'@'localhost' IDENTIFIED BY '$DBPASSWD';
|
||||
GRANT ALL PRIVILEGES ON nextcloud.* TO $DBADMIN@localhost;
|
||||
CREATE USER '$DBADMIN_'@'localhost' IDENTIFIED BY '$DBPASSWD_';
|
||||
GRANT ALL PRIVILEGES ON nextcloud.* TO $DBADMIN_@localhost;
|
||||
EXIT
|
||||
EOF
|
||||
|
||||
@ -224,17 +224,17 @@ EOF
|
||||
cd /var/www/nextcloud/
|
||||
|
||||
sudo -u www-data php occ maintenance:install --database \
|
||||
"mysql" --database-name "nextcloud" --database-user "$DBADMIN" --database-pass \
|
||||
"$DBPASSWD" --admin-user "$ADMINUSER" --admin-pass "$DBPASSWD"
|
||||
"mysql" --database-name "nextcloud" --database-user "$DBADMIN_" --database-pass \
|
||||
"$DBPASSWD_" --admin-user "$ADMINUSER_" --admin-pass "$DBPASSWD_"
|
||||
|
||||
sudo -u www-data php occ background:cron
|
||||
|
||||
sed -i '$s=^.*$= '\''memcache.local'\'' \=> '\''\\OC\\Memcache\\APCu'\'',\n);=' /var/www/nextcloud/config/config.php
|
||||
|
||||
sed -i "s/post_max_size=.*/post_max_size=$MAX_FILESIZE/" /var/www/nextcloud/.user.ini
|
||||
sed -i "s/post_max_size=.*/upload_max_filesize=$MAX_FILESIZE/" /var/www/nextcloud/.user.ini
|
||||
sed -i "s/post_max_size=.*/post_max_size=$MAX_FILESIZE/" /var/www/nextcloud/.htaccess
|
||||
sed -i "s/post_max_size=.*/upload_max_filesize=$MAX_FILESIZE/" /var/www/nextcloud/.htaccess
|
||||
sed -i "s/post_max_size=.*/post_max_size=$MAX_FILESIZE_/" /var/www/nextcloud/.user.ini
|
||||
sed -i "s/post_max_size=.*/upload_max_filesize=$MAX_FILESIZE_/" /var/www/nextcloud/.user.ini
|
||||
sed -i "s/post_max_size=.*/post_max_size=$MAX_FILESIZE_/" /var/www/nextcloud/.htaccess
|
||||
sed -i "s/post_max_size=.*/upload_max_filesize=$MAX_FILESIZE_/" /var/www/nextcloud/.htaccess
|
||||
|
||||
echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" > /tmp/crontab_http
|
||||
crontab -u www-data /tmp/crontab_http
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user