Installiert Nextcloud mit Standard Werten
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
7.5 KiB

#!/bin/bash
# ###############################################################################
# File: nextcloud_head.sh
# Project: SH Scripts
# File Created: Monday, 6th July 2020 11:05:48 am
# Author: Thomas Brinkmann (doyl@dsh.icu)
# -----
# Last Modified: Monday, 6th July 2020 9:34:46 pm
# Modified By: Thomas Brinkmann (doyl@dsh.icu>)
# -----
# Copyright 2020 - Thomas Brinkmann. All Rights Reserved.
# -----
# License Text
# Es ist Ihnen untersagt diese Software zu kopieren, manipulieren, verbreiten oder anderweitig ohne ausdrückliche Erlaubnis zu nutzen.
# Sie dürfen ebenfalls nicht den Copyright Hinweis entfernen.
#
# It is prohibited to copy, manipulate, distribute or otherwise use this software without express permission.
# You may also not remove the copyright notice.
# -----
# ###############################################################################
cd "/home"
LATEST_STABLE_RELEASE=19.0.0 #Nextcloud Version
DBPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
DBUSER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
ADMINPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
VAR_A=`uname -m`
show_spinner()
{
spin='-\|/'
i=0
while kill -0 $1 2>/dev/null
do
i=$(( (i+1) %4 ))
printf "\r\e[93m[ \e[36m${spin:$i:1} \e[93m] \e[93mPlease wait...\e[39m"
sleep .1
done
}
#https://download.nextcloud.com/server/releases/nextcloud-
download_latestnextcloud(){
echo -e "\n\e[92mDownloading latest nextcloud version..\e[39m"
wget -q -N -P /home https://download.nextcloud.com/server/releases/nextcloud-$LATEST_STABLE_RELEASE.zip >/dev/null &
show_spinner $!
}
install_Debian9(){
echo -e "\n\e[92mInstalling requirements...\e[39m"
apt-get install --yes --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" sudo
apt-get install -y zip unzip curl wget gnupg2 ca-certificates lsb-release apt-transport-https >/dev/null &
show_spinner $!
echo -e "\n\e[92mInstalling public key & source list...\e[39m"
wget -q -N https://packages.sury.org/php/apt.gpg
apt-key add apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php7.list
apt-get update >/dev/null &
show_spinner $!
echo -e "\n\e[92mInstalling PHP...\e[39m"
apt-get install -y php7.3 php7.3-cli php7.3-common >/dev/null &
show_spinner $!
echo -e "\n\e[92mInstalling Apache2 and MariaDB-Server..\e[39m"
apt-get install -y apache2 mariadb-server libapache2-mod-php7.4 >/dev/null &
show_spinner $!
echo -e "\n\e[92mInstallation PHP extentions...\e[39m"
apt-get install -y php7.3-fileinfo php7.3-bz2 php7.3-intl php7.3-ldap php7.3-smbclient php7.3-imap php7.3-bcmath php7.3-gmp php7.3-mysql php7.3-dom php7.3-simplexml php7.3-ssh2 php7.3-xml php7.3-xmlreader php7.3-curl php7.3-xmlwriter php7.3-zip php7.3-exif php7.3-ftp php7.3-gd php7.3-iconv php7.3-imagick php7.3-json php7.3-mbstring php7.3-posix php7.3-sockets php7.3-tokenizer >/dev/null &
show_spinner $!
echo -e "\n\e[92mWriting apache vhost config.."
echo "Alias /nextcloud \"/var/www/nextcloud/\"
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>" >> /etc/apache2/sites-available/nextcloud.conf
a2ensite nextcloud.conf >/dev/null
a2enmod rewrite >/dev/null
a2enmod headers >/dev/null
a2enmod env >/dev/null
a2enmod dir >/dev/null
a2enmod mime >/dev/null
service apache2 restart
echo -e "\n\e[92mConfiguring MariaDB...\e[39m"
echo "CREATE USER '$DBUSER'@'localhost' IDENTIFIED BY '$DBPASS';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO '$DBUSER'@'localhost';
FLUSH PRIVILEGES;" > /home/nextcloudheadless.sql
mysql -u root < /home/nextcloudheadless.sql
rm /home/nextcloudheadless.sql
download_latestnextcloud
echo -e "\n\e[92mExtracting Nextcloud...\e[39m"
cd "/home/"
unzip -o nextcloud-$LATEST_STABLE_RELEASE.zip >/dev/null &
show_spinner $!
echo -e "\n\e[92mMoving nextcloud to the document root..\e[39m"
cp -r nextcloud /var/www >/dev/null &
show_spinner $!
chown -R www-data:www-data /var/www/nextcloud
cd /var/www/nextcloud/
echo -e "\n\e[92mConfigure Nextcloud..\e[39m"
sudo -u www-data php7.3 occ maintenance:install --database "mysql" --database-name "nextcloud" --database-user "$DBUSER" --database-pass "$DBPASS" --admin-user "admin" --admin-pass "$ADMINPASS" >/dev/null &
show_spinner $!
echo -e "\n\e[92mWriting login details into file...\e[39m"
echo -e "\n
########## Nextcloud ##########\n
# Username: admin \n
# Password: $ADMINPASS \n
########## ## END ## ##########\n
\n
########## MySQL ##########\n
# Username: $DBUSER \n
# Password: $DBPASS \n
########## END ##########\n" > /home/Nextclound-Login-Details-README.txt
echo -e "\n\e[92mLogin details written to \e[93m/home/Nextclound-Login-Details-README.txt \e[39m"
}
clean_up(){
echo -e "\n\e[92mCleaning... \e[39m"
rm -R /home/nextcloud
rm /home/apt.gpg
rm /home/nextcloud-$LATEST_STABLE_RELEASE.zip
}
# CentOS vHOST
# DocumentRoot /var/www/nextcloud/
# ServerName your.server.com
#
# <Directory /var/www/nextcloud/>
# Require all granted
# AllowOverride All
# Options FollowSymLinks MultiViews
#
# <IfModule mod_dav.c>
# Dav off
# </IfModule>
#
# </Directory>
#</VirtualHost>
i=0
tput sc
while fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1 ; do
case $(($i % 4)) in
0 ) j="-" ;;
1 ) j="\\" ;;
2 ) j="|" ;;
3 ) j="/" ;;
esac
tput rc
echo -en "\r[$j] \e[93mWaiting for another process to finish...\e[39m"
sleep 0.5
((i=i+1))
done
echo -e "\n\e[92mPackage manager is done\e[39m"
echo -e "\e[36mPreparing Nextcloud installation..\e[39m"
echo -e "\e[36mChecking Operation system..\e[39m"
# CHECK OS
if [ "$VAR_A" = "x86_64" ]; then
check=`cat /etc/issue | grep -i 'Debian'`
if [ -n "$check" ]; then
apt-get update >/dev/null &
show_spinner $!
version=`cat /etc/debian_version | awk -F. '{print $1}'`
if [ $version -eq 10 ]; then
#Debian 10
echo -e "\nDebian $version\e[39m"
install_Debian9 # Currently it also works for Debian 10
clean_up
elif [ $version -eq 9 ]; then
#Debian 9 Check
echo -e "\nDebian $version\e[39m"
install_Debian9
clean_up
elif [ $version -eq 8 ]; then
#Debian 8 Check
echo "Debian $version\e[39m"
fi
fi
#Debian Check End
#Ubuntu
check=`cat /etc/issue | grep -i 'Ubuntu'`
if [ -n "$check" ]; then
apt-get update >/dev/null &
show_spinner $!
version=`lsb_release -sr | awk -F. '{print $1}'`
if [ $version -eq 20 ]; then
#Ubuntu 20
echo "Ubuntu $version"
elif [ $version -eq 18 ]; then
#Ubuntu 18
echo "Ubuntu $version"
elif [ $version -eq 16 ]; then
#Ubuntu 16
echo "Ubuntu $version"
fi
fi
#CentOS
check=`cat /etc/issue | grep -i 'CentOS'`
if [ -n "$check" ]; then
echo "CentOS is not supported yet"
fi
fi
echo -e "\e[39mEverything is done.\e[39m"