Skip to content

Instantly share code, notes, and snippets.

@bspavel
Last active August 15, 2018 16:58
Show Gist options
  • Save bspavel/6fdc6e32c9780f2974fd1a8bf578d56e to your computer and use it in GitHub Desktop.
Save bspavel/6fdc6e32c9780f2974fd1a8bf578d56e to your computer and use it in GitHub Desktop.
the installer of the nextcloud on the raspberry pi
#!/bin/bash
#https://pimylifeup.com/raspberry-pi-nextcloud-server/
#https://stackoverflow.com/questions/13322485/how-to-get-the-primary-ip-address-of-the-local-machine-on-linux-and-os-x
#https://unix.stackexchange.com/questions/293940/bash-how-can-i-make-press-any-key-to-continue
#https://stackoverflow.com/questions/638975/how-do-i-tell-if-a-regular-file-does-not-exist-in-bash
#https://www.cyberciti.biz/faq/bash-infinite-loop/
#https://stackoverflow.com/questions/2379829/while-loop-to-test-if-a-file-exists-in-bash
if [ "$(whoami)" != "root" ]; then
echo "Run script as ROOT please. (sudo !!!)"
exit
fi
# Disable Wi-Fi and Bluetooth
read -p "Do you want to disable modules Wi-Fi and Bluetooth? <y/N> " prompt
if [ "$prompt" = "y" ]; then
cat >> /boot/config.txt << "EOF"
dtoverlay=pi3-disable-wifi
dtoverlay=pi3-disable-bt
EOF
fi
sudo apt-get update -y && apt-get upgrade -y
sudo apt-get install apache2 -y
sudo apt-get install php7.0 php7.0-gd sqlite php7.0-sqlite php7.0-curl php7.0-zip php7.0-xml php7.0-mbstring -y
sudo service apache2 restart
cd /var/www/html
curl https://download.nextcloud.com/server/releases/nextcloud-13.0.5.tar.bz2 | sudo tar -jxv
sudo mkdir -p /var/www/html/nextcloud/data
sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod 750 /var/www/html/nextcloud/data
sudo mkdir -p /home/nextcloud
sudo mv -v /var/www/html/nextcloud/data /home/nextcloud/data
while [ ! -f /var/www/html/nextcloud/config/config.php ]
do
clear
echo "Please, visit:"
echo "http://"$(ip route get 1 | awk '{print $NF;exit}')"/nextcloud/"
echo "Then"
read -n 1 -s -r -p "Press any key to continue"
sleep 10
done
cd /var/www/html/nextcloud/config
sudo cp -p config.php config.php.bk
sed -i "s#^'datadirectory' => '/var/www/nextcloud/data'#'datadirectory' => '/home/nextcloud/data',#" /var/www/html/nextcloud/config/config.php
sed -i 's/^;date.timezone =/date.timezone=Europe\/Kiev/' /etc/php/7.0/apache2/php.ini
sed -i 's/^upload_max_filesize = 2M/upload_max_filesize = 300M/' /etc/php/7.0/apache2/php.ini
sed -i 's/^post_max_size = 8M/post_max_size = 300M/' /etc/php/7.0/apache2/php.ini
sudo service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment