2016-06-03 16:27:39 +03:00
#!/bin/bash
2017-04-09 23:43:30 +03:00
# shellcheck disable=2034,2059
true
# shellcheck source=lib.sh
2018-05-06 19:08:18 +03:00
NCDB = 1 && FIRST_IFACE = 1 && CHECK_CURRENT_REPO = 1 . <( curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
2017-04-09 23:43:30 +03:00
unset FIRST_IFACE
unset CHECK_CURRENT_REPO
2018-05-06 19:08:18 +03:00
unset NCDB
2016-06-03 16:27:39 +03:00
2019-02-27 01:24:22 +03:00
# T&M Hansson IT AB © - 2019, https://www.hanssonit.se/
2016-06-03 16:27:39 +03:00
2017-04-24 23:16:17 +03:00
## If you want debug mode, please activate it further down in the code at line ~60
2016-09-29 22:37:18 +03:00
2018-05-06 19:08:18 +03:00
# FUNCTIONS #
msg_box( ) {
local PROMPT = " $1 "
whiptail --msgbox " ${ PROMPT } " " $WT_HEIGHT " " $WT_WIDTH "
}
2017-04-15 00:20:34 +03:00
is_root( ) {
if [ [ " $EUID " -ne 0 ] ]
then
return 1
else
return 0
fi
}
2017-12-10 05:43:29 +03:00
root_check( ) {
if ! is_root
then
msg_box " Sorry, you are not root. You now have two options:
2018-02-06 19:09:44 +03:00
2017-12-10 05:43:29 +03:00
1. With SUDO directly:
a) :~$ sudo bash $SCRIPTS /name-of-script.sh
2. Become ROOT and then type your command:
a) :~$ sudo -i
b) :~# $SCRIPTS /name-of-script.sh
2018-02-06 19:09:44 +03:00
2017-12-10 05:43:29 +03:00
In both cases above you can leave out $SCRIPTS / if the script
is directly in your PATH.
More information can be found here: https://unix.stackexchange.com/a/3064"
exit 1
fi
}
2019-04-10 23:00:36 +03:00
# Checks if site is reachable with a HTTP 200 status
site_200( ) {
if [ [ " $( curl -sfIL --retry 3 " $1 " | grep Status: | awk '{print$2}' ) " -eq 200 ] ]
2017-04-15 00:20:34 +03:00
then
return 0
else
return 1
fi
}
2019-04-10 23:00:36 +03:00
network_ok( ) {
print_text_in_color " $ICyan " "Testing if network is OK..."
install_if_not network-manager
if ! service network-manager restart > /dev/null
then
service networking restart > /dev/null
fi
sleep 5 && site_200 github.com
}
2018-05-06 19:08:18 +03:00
check_command( ) {
if ! " $@ " ;
then
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " " Sorry but something went wrong. Please report this issue to $ISSUES and include the output of the error message. Thank you! "
2018-12-13 23:34:03 +03:00
print_text_in_color " $Red " " $* failed "
2018-05-06 19:08:18 +03:00
exit 1
fi
}
2019-03-10 22:56:40 +03:00
# Colors
Color_Off = '\e[0m'
IRed = '\e[0;91m'
IGreen = '\e[0;92m'
ICyan = '\e[0;96m'
print_text_in_color( ) {
printf "%b%s%b\n" " $1 " " $2 " " $Color_Off "
}
2018-05-06 19:08:18 +03:00
# END OF FUNCTIONS #
2016-09-25 23:48:36 +03:00
# Check if root
2017-12-05 23:21:42 +03:00
root_check
2016-06-03 16:27:39 +03:00
2016-11-15 14:14:51 +03:00
# Check network
2017-04-09 23:43:30 +03:00
if network_ok
2016-11-15 14:14:51 +03:00
then
2018-12-18 01:27:01 +03:00
printf " ${ IGreen } Online! ${ Color_Off } \n "
2016-11-15 14:14:51 +03:00
else
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Setting correct interface..."
2017-04-15 00:20:34 +03:00
[ -z " $IFACE " ] && IFACE = $( lshw -c network | grep "logical name" | awk '{print $3; exit}' )
2017-04-09 23:43:30 +03:00
# Set correct interface
2018-05-06 19:08:18 +03:00
cat <<-SETDHCP > "/etc/netplan/01-netcfg.yaml"
network:
version: 2
renderer: networkd
ethernets:
$IFACE :
dhcp4: yes
dhcp6: yes
SETDHCP
check_command netplan apply
check_command service network-manager restart
ip link set " $IFACE " down
wait
ip link set " $IFACE " up
wait
check_command service network-manager restart
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Checking connection..."
2018-11-18 14:18:17 +03:00
sleep 1
2018-05-06 19:08:18 +03:00
if ! nslookup github.com
then
2018-11-18 14:18:17 +03:00
msg_box " The script failed to get an address from DHCP.
You must have a working network connection to run this script.
You will now be provided with the option to set a static IP manually instead."
2018-12-11 00:05:48 +03:00
# Copy old interfaces files
msg_box " Copying old netplan.io config files file to:
/tmp/netplan_io_backup/"
2019-04-10 23:00:36 +03:00
if [ -d /etc/netplan/ ]
2018-12-11 00:05:48 +03:00
then
mkdir -p /tmp/netplan_io_backup
check_command cp -vR /etc/netplan/* /tmp/netplan_io_backup/
fi
2018-11-18 14:18:17 +03:00
# Ask for IP address
cat << ENTE RIP
+----------------------------------------------------------+
| Please enter the static IP address you want to set, |
| including the subnet. Example: 192.168.1.100/24 |
+----------------------------------------------------------+
ENTERIP
echo
read -r LANIP
echo
# Ask for gateway address
cat << ENTE RGATEWAY
+----------------------------------------------------------+
| Please enter the gateway address you want to set, |
| Example: 192.168.1.1 |
+----------------------------------------------------------+
ENTERGATEWAY
echo
read -r GATEWAYIP
echo
# Create the Static IP file
cat <<-IPCONFI G > /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
$IFACE : #object name
dhcp4: no # dhcp v4 disable
dhcp6: no # dhcp v6 disable
addresses: [ $LANIP ] # client IP address
gateway4: $GATEWAYIP # gateway address
nameservers:
addresses: [ 9.9.9.9,149.112.112.112] #name servers
IPCONFIG
msg_box " These are your settings, please make sure they are correct:
$( cat /etc/netplan/01-netcfg.yaml) "
netplan try
2018-05-06 19:08:18 +03:00
fi
fi
# Check network again
if network_ok
then
2018-12-18 01:27:01 +03:00
printf " ${ IGreen } Online! ${ Color_Off } \n "
2018-05-06 19:08:18 +03:00
else
2018-11-18 14:18:17 +03:00
msg_box " Network NOT OK. You must have a working network connection to run this script.
Please contact us for support:
https://shop.hanssonit.se/product/premium-support-per-30-minutes/
Please also post this issue on: https://github.com/nextcloud/vm/issues"
2018-05-06 19:08:18 +03:00
exit 1
2016-11-15 14:14:51 +03:00
fi
2016-06-07 22:10:10 +03:00
2018-05-06 19:08:18 +03:00
# shellcheck source=lib.sh
NCDB = 1 && CHECK_CURRENT_REPO = 1 && NC_UPDATE = 1 . <( curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
unset NC_UPDATE
unset CHECK_CURRENT_REPO
unset NCDB
2017-04-24 23:16:17 +03:00
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG = 0
debug_mode
2018-05-06 19:08:18 +03:00
# Nextcloud 13 is required.
lowest_compatible_nc 13
2017-12-05 23:21:42 +03:00
2018-05-06 19:08:18 +03:00
# Check that this run on the PostgreSQL VM
if ! which psql > /dev/null
then
2018-12-13 23:34:03 +03:00
print_text_in_color " $Red " "This script is intended to be run on then PostgreSQL VM but PostgreSQL is not installed."
print_text_in_color " $Red " "Aborting..."
2016-09-25 23:48:36 +03:00
exit 1
fi
2016-06-03 16:27:39 +03:00
2017-12-10 05:43:29 +03:00
# Is this run as a pure root user?
if is_root
then
if [ [ " $UNIXUSER " = = "ncadmin" ] ]
then
sleep 1
else
if [ -z " $UNIXUSER " ]
then
msg_box " You seem to be running this as the pure root user.
You must run this as a regular user with sudo permissions.
Please create a user with sudo permissions and the run this command:
sudo -u [ user-with-sudo-permissions] sudo bash /var/scripts/nextcloud-startup-script.sh
We will do this for you when you hit OK."
2018-08-05 18:34:42 +03:00
download_static_script adduser
bash $SCRIPTS /adduser.sh " $SCRIPTS /nextcloud-startup-script.sh "
rm $SCRIPTS /adduser.sh
2017-12-10 05:43:29 +03:00
else
msg_box " You probably see this message if the user 'ncadmin' does not exist on the system,
2018-09-05 21:29:53 +03:00
which could be the case if you are running directly from the scripts on Gihub and not the VM.
2017-12-10 05:43:29 +03:00
As long as the user you created have sudo permissions it' s safe to continue .
2018-09-05 21:29:53 +03:00
This would be the case if you created a new user with the script in the previous step.
2017-12-10 05:43:29 +03:00
2018-09-05 21:29:53 +03:00
If the user you are running this script with is a user that doesn' t have sudo permissions,
2017-12-10 05:43:29 +03:00
please abort this script and report this issue to $ISSUES ."
fi
fi
fi
2017-08-20 23:36:37 +03:00
# Check if dpkg or apt is running
is_process_running apt
2018-02-06 19:09:44 +03:00
is_process_running dpkg
2017-08-20 23:36:37 +03:00
2017-02-01 06:13:46 +03:00
echo
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Getting scripts from GitHub to be able to run the first setup..."
2018-11-18 14:18:17 +03:00
# Scripts in static (.sh, .php, .py)
2017-04-09 23:43:30 +03:00
download_static_script temporary-fix
download_static_script update
download_static_script trusted
download_static_script test_connection
download_static_script setup_secure_permissions_nextcloud
2018-05-06 19:08:18 +03:00
download_static_script change_db_pass
2017-04-09 23:43:30 +03:00
download_static_script nextcloud
download_static_script update-config
download_static_script index
2017-06-09 13:27:33 +03:00
download_le_script activate-ssl
2016-09-25 23:48:36 +03:00
2017-04-09 23:43:30 +03:00
mv $SCRIPTS /index.php $HTML /index.php && rm -f $HTML /html/index.html
chmod 750 $HTML /index.php && chown www-data:www-data $HTML /index.php
2016-09-25 23:48:36 +03:00
# Change 000-default to $WEB_ROOT
2017-04-09 23:43:30 +03:00
sed -i " s|DocumentRoot /var/www/html|DocumentRoot $HTML |g " /etc/apache2/sites-available/000-default.conf
2016-06-03 16:27:39 +03:00
2018-08-09 02:23:48 +03:00
# Make possible to see the welcome screen (without this php-fpm won't reach it)
sed -i '14i\ # http://lost.l-w.ca/0x05/apache-mod_proxy_fcgi-and-php-fpm/' /etc/apache2/sites-available/000-default.conf
sed -i '15i\ <FilesMatch "\.php$">' /etc/apache2/sites-available/000-default.conf
sed -i '16i\ <If "-f %{SCRIPT_FILENAME}">' /etc/apache2/sites-available/000-default.conf
sed -i '17i\ SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"' /etc/apache2/sites-available/000-default.conf
sed -i '18i\ </If>' /etc/apache2/sites-available/000-default.conf
sed -i '19i\ </FilesMatch>' /etc/apache2/sites-available/000-default.conf
sed -i '20i\ ' /etc/apache2/sites-available/000-default.conf
2016-06-03 16:27:39 +03:00
# Make $SCRIPTS excutable
chmod +x -R $SCRIPTS
chown root:root -R $SCRIPTS
# Allow $UNIXUSER to run figlet script
2017-04-09 23:43:30 +03:00
chown " $UNIXUSER " :" $UNIXUSER " " $SCRIPTS /nextcloud.sh "
2016-06-03 16:27:39 +03:00
2017-12-05 23:21:42 +03:00
msg_box " This script will configure your Nextcloud and activate SSL.
It will also do the following:
- Generate new SSH keys for the server
2018-08-06 21:33:39 +03:00
- Generate new PostgreSQL password
2017-12-05 23:21:42 +03:00
- Install selected apps and automatically configure them
- Detect and set hostname
- Upgrade your system and Nextcloud to latest version
- Set secure permissions to Nextcloud
- Set new passwords to Linux and Nextcloud
- Set new keyboard layout
- Change timezone
2018-09-20 19:33:58 +03:00
- Change mirrors depending on your location
2018-08-06 21:33:39 +03:00
- Set correct Rewriterules for Nextcloud
- Copy content from .htaccess to .user.ini ( because we use php-fpm)
- Add additional options if you choose them
2017-12-05 23:21:42 +03:00
The script will take about 10 minutes to finish,
depending on your internet connection.
2018-10-14 16:44:19 +03:00
###################### T&M Hansson IT - $(date +"%Y") ######################"
2016-06-03 16:27:39 +03:00
clear
2017-02-08 19:41:40 +03:00
# Set keyboard layout
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " " Current keyboard layout is $( localectl status | grep "Layout" | awk '{print $3}' ) "
2017-02-24 04:22:57 +03:00
if [ [ "no" = = $( ask_yes_or_no "Do you want to change keyboard layout?" ) ] ]
then
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Not changing keyboard layout..."
2017-04-09 23:43:30 +03:00
sleep 1
clear
2017-02-24 04:22:57 +03:00
else
2017-04-09 23:43:30 +03:00
dpkg-reconfigure keyboard-configuration
2017-12-05 23:21:42 +03:00
clear
2017-02-24 04:22:57 +03:00
fi
2017-02-08 19:41:40 +03:00
2018-03-31 15:12:33 +03:00
# Change Timezone
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " " Current timezone is $( cat /etc/timezone) "
2018-03-31 15:12:33 +03:00
if [ [ "no" = = $( ask_yes_or_no "Do you want to change the timezone?" ) ] ]
then
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Not changing timezone..."
2018-03-31 15:12:33 +03:00
sleep 1
clear
else
dpkg-reconfigure tzdata
2018-05-06 19:08:18 +03:00
clear
2018-03-31 15:12:33 +03:00
fi
2018-09-20 19:33:58 +03:00
# Check where the best mirrors are and update
msg_box " To make downloads as fast as possible when updating you should have mirrors that are as close to you as possible.
This VM comes with mirrors based on servers in that where used when the VM was released and packaged.
If you are located outside of Europe, we recomend you to change the mirrors so that downloads are faster."
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Checking current mirror..."
print_text_in_color " $ICyan " " Your current server repository is: $REPO "
2018-09-20 19:33:58 +03:00
if [ [ "no" = = $( ask_yes_or_no "Do you want to try to find a better mirror?" ) ] ]
then
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " " Keeping $REPO as mirror... "
2018-09-20 19:33:58 +03:00
sleep 1
else
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Locating the best mirrors..."
2018-09-20 19:33:58 +03:00
apt update -q4 & spinner_loading
apt install python-pip -y
pip install \
--upgrade pip \
apt-select
check_command apt-select -m up-to-date -t 5 -c -C " $( localectl status | grep "Layout" | awk '{print $3}' ) "
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup && \
if [ -f sources.list ]
then
sudo mv sources.list /etc/apt/
fi
fi
clear
2016-09-29 21:44:12 +03:00
# Pretty URLs
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Setting RewriteBase to \"/\" in config.php..."
2016-12-27 13:03:55 +03:00
chown -R www-data:www-data $NCPATH
2018-09-07 18:25:13 +03:00
occ_command config:system:set overwrite.cli.url --value= "http://localhost/"
2018-03-02 00:18:53 +03:00
occ_command config:system:set htaccess.RewriteBase --value= "/"
occ_command maintenance:update:htaccess
2017-04-09 23:43:30 +03:00
bash $SECURE & spinner_loading
2016-09-29 21:44:12 +03:00
2016-11-01 22:42:24 +03:00
# Generate new SSH Keys
2017-04-09 23:43:30 +03:00
printf "\nGenerating new SSH keys for the server...\n"
2016-06-03 16:27:39 +03:00
rm -v /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
2018-05-06 19:08:18 +03:00
# Generate new PostgreSQL password
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "Generating new PostgreSQL password..."
2018-05-06 19:08:18 +03:00
check_command bash " $SCRIPTS /change_db_pass.sh "
sleep 3
clear
2017-01-25 23:39:50 +03:00
2017-12-05 23:21:42 +03:00
msg_box " The following script will install a trusted
SSL certificate through Let' s Encrypt.
It' s recommended to use SSL together with Nextcloud.
Please open port 80 and 443 to this servers IP before you continue .
More information can be found here:
https://www.techandme.se/open-port-80-443/"
2017-03-05 20:55:33 +03:00
# Let's Encrypt
if [ [ "yes" = = $( ask_yes_or_no "Do you want to install SSL?" ) ] ]
then
bash $SCRIPTS /activate-ssl.sh
else
echo
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " " OK, but if you want to run it later, just type: sudo bash $SCRIPTS /activate-ssl.sh "
2017-04-09 23:43:30 +03:00
any_key "Press any key to continue..."
2017-03-05 20:55:33 +03:00
fi
clear
2018-03-31 15:12:33 +03:00
# Install Apps
2017-03-02 11:17:56 +03:00
whiptail --title "Which apps do you want to install?" --checklist --separate-output "Automatically configure and install selected apps\nSelect by pressing the spacebar" " $WT_HEIGHT " " $WT_WIDTH " 4 \
2017-06-16 02:48:36 +03:00
"Fail2ban" "(Extra Bruteforce protection) " OFF \
2018-08-06 21:33:39 +03:00
"Adminer" "(PostgreSQL GUI) " OFF \
2018-03-02 00:18:53 +03:00
"Netdata" "(Real-time server monitoring) " OFF \
2018-08-09 02:23:48 +03:00
"Collabora" "(Online editing [2GB RAM]) " OFF \
"OnlyOffice" "(Online editing [4GB RAM]) " OFF \
2019-02-09 12:52:35 +03:00
"Bitwarden" "(External password manager) " OFF \
2018-08-09 02:23:48 +03:00
"FullTextSearch" "(Elasticsearch for Nextcloud [2GB RAM]) " OFF \
"PreviewGenerator" "(Pre-generate previews) " OFF \
2018-12-11 23:27:48 +03:00
"Talk" "(Nextcloud Video calls and chat) " OFF 2>results
2017-01-07 18:39:36 +03:00
2017-03-02 21:49:52 +03:00
while read -r -u 9 choice
2017-01-07 18:39:36 +03:00
do
2017-04-09 23:43:30 +03:00
case $choice in
2017-06-16 02:48:36 +03:00
Fail2ban)
2018-08-09 14:25:11 +03:00
clear
2017-06-16 02:48:36 +03:00
run_app_script fail2ban
; ;
2018-02-06 19:09:44 +03:00
2018-08-06 21:33:39 +03:00
Adminer)
2018-08-09 14:25:11 +03:00
clear
2018-08-06 21:33:39 +03:00
run_app_script adminer
2018-02-06 19:09:44 +03:00
; ;
2018-05-06 19:08:18 +03:00
Netdata)
2018-08-09 14:25:11 +03:00
clear
2018-05-06 19:08:18 +03:00
run_app_script netdata
2017-05-22 19:36:07 +03:00
; ;
2017-06-16 02:48:36 +03:00
2017-06-01 20:36:16 +03:00
OnlyOffice)
2018-08-09 14:25:11 +03:00
clear
2017-06-01 20:36:16 +03:00
run_app_script onlyoffice
; ;
2017-06-16 02:48:36 +03:00
2017-04-09 23:43:30 +03:00
Collabora)
2018-08-09 14:25:11 +03:00
clear
2017-04-09 23:43:30 +03:00
run_app_script collabora
; ;
2018-09-12 11:52:08 +03:00
Bitwarden)
2018-08-09 14:25:11 +03:00
clear
2018-10-17 18:52:23 +03:00
run_app_script tmbitwarden
2017-04-09 23:43:30 +03:00
; ;
2018-03-02 00:18:53 +03:00
FullTextSearch)
2018-08-09 14:25:11 +03:00
clear
2018-03-02 01:25:11 +03:00
run_app_script fulltextsearch
2018-08-09 02:23:48 +03:00
; ;
PreviewGenerator)
2018-08-09 14:25:11 +03:00
clear
2018-08-09 02:23:48 +03:00
run_app_script previewgenerator
; ;
2017-04-09 23:43:30 +03:00
2018-02-06 19:09:44 +03:00
Talk)
2018-08-09 14:25:11 +03:00
clear
2018-06-09 14:27:24 +03:00
run_app_script talk
2018-02-06 19:09:44 +03:00
; ;
2017-04-09 23:43:30 +03:00
*)
; ;
esac
2017-03-02 21:49:52 +03:00
done 9< results
2017-03-03 00:23:56 +03:00
rm -f results
2016-10-27 14:14:47 +03:00
clear
2018-12-18 00:22:45 +03:00
# Change passwords
# CLI USER
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " " For better security, change the system user password for [ $( getent group sudo | cut -d: -f4 | cut -d, -f1) ] "
2017-04-09 23:43:30 +03:00
any_key "Press any key to change password for system user..."
while true
do
2018-02-07 23:30:48 +03:00
sudo passwd " $( getent group sudo | cut -d: -f4 | cut -d, -f1) " && break
2017-04-09 23:43:30 +03:00
done
2017-03-05 20:55:33 +03:00
echo
clear
2018-12-18 00:22:45 +03:00
# NEXTCLOUD USER
2018-03-02 00:18:53 +03:00
NCADMIN = $( occ_command user:list | awk '{print $3}' )
2019-01-19 03:10:01 +03:00
print_text_in_color " $ICyan " " The current admin user in Nextcloud GUI is [ $NCADMIN ] "
2018-12-18 00:22:45 +03:00
print_text_in_color " $ICyan " "We will now replace this user with your own."
2019-01-19 03:10:01 +03:00
any_key "Press any key to replace the current admin user for Nextcloud..."
2018-12-18 00:22:45 +03:00
# Create new user
2017-04-09 23:43:30 +03:00
while true
do
2018-12-18 00:22:45 +03:00
print_text_in_color " $ICyan " "Please enter the username for your new user:"
read -r NEWUSER
sudo -u www-data $NCPATH /occ user:add " $NEWUSER " -g admin && break
2017-04-09 23:43:30 +03:00
done
2018-12-18 00:22:45 +03:00
# Delete old user
if [ [ " $NCADMIN " ] ]
then
print_text_in_color " $ICyan " " Deleting $NCADMIN ... "
occ_command user:delete " $NCADMIN "
fi
2017-02-01 00:25:16 +03:00
clear
2016-06-03 16:27:39 +03:00
2018-12-18 00:22:45 +03:00
# Set notifications for admin
NCADMIN = $( occ_command user:list | awk '{print $3}' )
occ_command notification:generate -l "Please remember to setup SMTP to be able to send shared links, user notficatoins and more via email. Please go here and start setting it up: https://your-nextcloud/settings/admin." " $NCADMIN " "Please setup SMTP"
occ_command notification:generate -l "If you need support, please visit the shop: https://shop.hanssonit.se" " $NCADMIN " "Do you need support?"
2018-10-31 20:44:28 +03:00
2016-12-12 04:05:26 +03:00
# Fixes https://github.com/nextcloud/vm/issues/58
a2dismod status
2018-08-09 02:23:48 +03:00
restart_webserver
2016-12-12 04:05:26 +03:00
2018-08-09 02:23:48 +03:00
# Increase max filesize (expects that changes are made in $PHP_INI)
2016-09-26 19:41:39 +03:00
# Here is a guide: https://www.techandme.se/increase-max-file-size/
2018-08-09 02:23:48 +03:00
configure_max_upload
2016-09-26 19:41:39 +03:00
2018-03-31 15:12:33 +03:00
# Extra configurations
whiptail --title "Extra configurations" --checklist --separate-output "Choose what you want to configure\nSelect by pressing the spacebar" " $WT_HEIGHT " " $WT_WIDTH " 4 \
"Security" "(Add extra security based on this http://goo.gl/gEJHi7)" OFF \
2018-08-09 02:23:48 +03:00
"ModSecurity" "(Add ModSecurity for Apache2" OFF \
2019-03-16 01:50:19 +03:00
"Static IP" "(Set static IP in Ubuntu with netplan.io)" OFF \
"Automatic updates" "(Automatically update your server every week on Sundays)" OFF 2>results
2018-03-31 15:12:33 +03:00
while read -r -u 9 choice
do
case $choice in
"Security" )
2018-08-09 14:25:11 +03:00
clear
2018-03-31 15:12:33 +03:00
run_static_script security
; ;
2018-08-09 02:23:48 +03:00
"ModSecurity" )
2018-08-09 14:25:11 +03:00
clear
2018-08-09 02:23:48 +03:00
run_static_script modsecurity
; ;
2018-03-31 15:12:33 +03:00
"Static IP" )
2018-08-09 14:25:11 +03:00
clear
2018-11-18 14:18:17 +03:00
run_static_script static_ip
2018-03-31 15:12:33 +03:00
; ;
2019-03-16 01:50:19 +03:00
"Automatic updates" )
clear
run_static_script automatic_updates
; ;
2018-03-31 15:12:33 +03:00
*)
; ;
esac
done 9< results
rm -f results
2019-01-17 02:32:42 +03:00
# Calculate the values of PHP-FPM based on the amount of RAM available (minimum 2 GB or 8 children)
2019-01-21 10:59:46 +03:00
calculate_php_fpm
2018-08-09 02:23:48 +03:00
2019-02-08 20:11:12 +03:00
# Run again if values are reset on last run
calculate_php_fpm
2016-07-01 01:45:39 +03:00
# Add temporary fix if needed
bash $SCRIPTS /temporary-fix.sh
2017-04-09 23:43:30 +03:00
rm " $SCRIPTS " /temporary-fix.sh
2016-07-01 01:45:39 +03:00
2016-06-03 16:27:39 +03:00
# Cleanup 1
2018-03-02 00:18:53 +03:00
occ_command maintenance:repair
2018-05-06 19:08:18 +03:00
rm -f " $SCRIPTS /ip.sh "
rm -f " $SCRIPTS /change_db_pass.sh "
2017-04-09 23:43:30 +03:00
rm -f " $SCRIPTS /test_connection.sh "
rm -f " $SCRIPTS /instruction.sh "
rm -f " $NCDATA /nextcloud.log "
rm -f " $SCRIPTS /nextcloud-startup-script.sh "
find /root " /home/ $UNIXUSER " -type f \( -name '*.sh*' -o -name '*.html*' -o -name '*.tar*' -o -name '*.zip*' \) -delete
sed -i "s|instruction.sh|nextcloud.sh|g" " /home/ $UNIXUSER /.bash_profile "
truncate -s 0 \
/root/.bash_history \
" /home/ $UNIXUSER /.bash_history " \
/var/spool/mail/root \
" /var/spool/mail/ $UNIXUSER " \
/var/log/apache2/access.log \
/var/log/apache2/error.log \
/var/log/cronjobs_success.log
sed -i "s|sudo -i||g" " /home/ $UNIXUSER /.bash_profile "
2016-06-26 21:44:45 +03:00
cat << RCLOCAL > "/etc/rc.local"
2016-06-03 16:27:39 +03:00
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
2016-06-26 21:44:45 +03:00
RCLOCAL
2017-10-04 22:23:59 +03:00
cat << ROOTNEWPRO FILE > "/root/.bash_profile"
# ~/.profile: executed by Bourne-compatible login shells.
if [ "/bin/bash" ]
then
if [ -f ~/.bashrc ]
then
. ~/.bashrc
fi
fi
if [ -x /var/scripts/nextcloud-startup-script.sh ]
then
/var/scripts/nextcloud-startup-script.sh
fi
if [ -x /var/scripts/history.sh ]
then
/var/scripts/history.sh
fi
mesg n
ROOTNEWPROFILE
2018-09-07 01:07:45 +03:00
# Download all app scripts
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " " Downloading all the latest app scripts to $SCRIPTS /apps... "
2018-09-07 01:07:45 +03:00
mkdir -p $SCRIPTS /apps
cd $SCRIPTS /apps
check_command curl -s https://codeload.github.com/nextcloud/vm/tar.gz/master | tar -xz --strip= 2 vm-master/apps
2017-04-09 23:43:30 +03:00
# Upgrade system
2018-12-18 01:27:01 +03:00
print_text_in_color " $ICyan " "System will now upgrade..."
2017-04-09 23:43:30 +03:00
bash $SCRIPTS /update.sh
# Cleanup 2
apt autoremove -y
apt autoclean
2016-12-16 16:30:12 +03:00
2016-12-02 18:21:32 +03:00
# Success!
2017-12-05 23:21:42 +03:00
msg_box " Congratulations! You have successfully installed Nextcloud!
2018-02-06 20:38:18 +03:00
2018-02-06 19:09:44 +03:00
Login to Nextcloud in your browser:
2018-03-31 15:12:33 +03:00
- IP: $ADDRESS
2018-02-06 19:09:44 +03:00
- Hostname: $( hostname -f)
2017-12-05 23:21:42 +03:00
2018-10-14 16:44:19 +03:00
SUPPORT:
Please ask for help in the forums, visit our shop to buy support,
or buy a yearly subscription from Nextcloud:
- SUPPORT: https://shop.hanssonit.se/product/premium-support-per-30-minutes/
- FORUM: https://help.nextcloud.com/
- SUBSCRIPTION: https://nextcloud.com/pricing/ ( Please refer to @enoch85)
Please report any bugs here: https://github.com/nextcloud/vm/issues
TIPS & TRICKS:
2018-02-06 19:09:44 +03:00
1. Publish your server online: https://goo.gl/iUGE2U
2018-10-14 16:44:19 +03:00
2018-05-06 19:08:18 +03:00
2. To login to PostgreSQL just type: sudo -u postgres psql nextcloud_db
2018-10-14 16:44:19 +03:00
2018-02-06 19:09:44 +03:00
3. To update this VM just type: sudo bash /var/scripts/update.sh
2018-10-14 16:44:19 +03:00
2018-05-22 21:25:16 +03:00
4. Change IP to something outside DHCP: sudo nano /etc/netplan/01-netcfg.yaml
2018-10-14 16:44:19 +03:00
5. For a better experiance it' s a good idea to setup an email account here:
https://yourcloud.xyz/settings/admin
######################### T&M Hansson IT - $(date +"%Y") ######################### "
2016-12-12 02:15:18 +03:00
2017-04-09 23:43:30 +03:00
# Set trusted domain in config.php
2017-05-29 16:27:13 +03:00
if [ -f " $SCRIPTS " /trusted.sh ]
then
bash " $SCRIPTS " /trusted.sh
rm -f " $SCRIPTS " /trusted.sh
fi
2016-12-02 18:23:35 +03:00
2016-12-16 16:30:12 +03:00
# Prefer IPv6
sed -i "s|precedence ::ffff:0:0/96 100|#precedence ::ffff:0:0/96 100|g" /etc/gai.conf
2016-06-03 16:27:39 +03:00
# Reboot
2017-04-09 23:43:30 +03:00
any_key "Installation finished, press any key to reboot system..."
2017-06-09 13:27:33 +03:00
rm -f " $SCRIPTS /nextcloud-startup-script.sh "
2016-06-03 16:27:39 +03:00
reboot