mirror of
https://github.com/EV21/uberspace-helper.git
synced 2026-10-08 04:43:18 +02:00
update uberspace-nextcloud-installer.sh
This commit is contained in:
1 file changed
+42
-33
@@ -13,12 +13,17 @@ function install_nextcloud
|
|||||||
# using bash substring syntax to remove the 9 characters "password="
|
# using bash substring syntax to remove the 9 characters "password="
|
||||||
MYSQL_PASSWORD=${MYSQL_PASSWORD_STR:9}
|
MYSQL_PASSWORD=${MYSQL_PASSWORD_STR:9}
|
||||||
|
|
||||||
rm ~/html/nocontent.html
|
if [ -e ~/html/nocontent.html ]
|
||||||
cd ~/html || exit
|
then rm ~/html/nocontent.html
|
||||||
|
fi
|
||||||
|
# shellcheck disable=2088
|
||||||
|
if [ "$(ls --almost-all ~/html/)" ]; then echo '~/html is not empty, abort!'; exit 1; fi
|
||||||
|
cd ~/html
|
||||||
echo "Downloading Nextcloud to ~/html/"
|
echo "Downloading Nextcloud to ~/html/"
|
||||||
curl https://download.nextcloud.com/server/releases/latest.tar.bz2 |
|
curl --progress-bar https://download.nextcloud.com/server/releases/latest.tar.bz2 |
|
||||||
tar -xjf - --strip-components=1
|
tar -xjf - --strip-components=1
|
||||||
mysql --verbose --execute="CREATE DATABASE ${USER}_nextcloud"
|
mysql --verbose --execute="CREATE DATABASE ${USER}_nextcloud"
|
||||||
|
echo "Installing Nextcloud"
|
||||||
php ~/html/occ maintenance:install \
|
php ~/html/occ maintenance:install \
|
||||||
--admin-user "${NEXTCLOUD_ADMIN_USER}" \
|
--admin-user "${NEXTCLOUD_ADMIN_USER}" \
|
||||||
--admin-pass "${NEXTCLOUD_ADMIN_PASS}" \
|
--admin-pass "${NEXTCLOUD_ADMIN_PASS}" \
|
||||||
@@ -63,18 +68,9 @@ function setup_domains
|
|||||||
{
|
{
|
||||||
echo "You currently have configured the following domains:"
|
echo "You currently have configured the following domains:"
|
||||||
uberspace web domain list
|
uberspace web domain list
|
||||||
while true
|
if yes-no_question "Do you want to add another domain to the web configuration of your uberspace?"
|
||||||
do
|
then add_domain
|
||||||
read -r -p "Do you want to add another domain to the web configuration of your uberspace? (y/n) " ANSWER
|
fi
|
||||||
case $ANSWER in
|
|
||||||
[Yy]* | [Jj]* )
|
|
||||||
add_domain
|
|
||||||
break;;
|
|
||||||
[Nn]* )
|
|
||||||
break;;
|
|
||||||
* ) echo "Please answer yes or no. ";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_domain
|
function add_domain
|
||||||
@@ -87,8 +83,8 @@ function setup_php
|
|||||||
{
|
{
|
||||||
uberspace tools version use php 8.0
|
uberspace tools version use php 8.0
|
||||||
echo "Applying relevant PHP settings for Nextcloud"
|
echo "Applying relevant PHP settings for Nextcloud"
|
||||||
touch ~/etc/php.d/opcache.ini
|
touch ~/etc/php.d/opcache.ini
|
||||||
cat << end_of_content > ~/etc/php.d/opcache.ini
|
cat << end_of_content > ~/etc/php.d/opcache.ini
|
||||||
opcache.enable=1
|
opcache.enable=1
|
||||||
opcache.enable_cli=1
|
opcache.enable_cli=1
|
||||||
opcache.interned_strings_buffer=16
|
opcache.interned_strings_buffer=16
|
||||||
@@ -99,17 +95,17 @@ opcache.revalidate_freq=1
|
|||||||
end_of_content
|
end_of_content
|
||||||
|
|
||||||
touch ~/etc/php.d/apcu.ini
|
touch ~/etc/php.d/apcu.ini
|
||||||
cat << end_of_content > ~/etc/php.d/apcu.ini
|
cat << end_of_content > ~/etc/php.d/apcu.ini
|
||||||
apc.enable_cli=1
|
apc.enable_cli=1
|
||||||
end_of_content
|
end_of_content
|
||||||
|
|
||||||
touch ~/etc/php.d/memory_limit.ini
|
touch ~/etc/php.d/memory_limit.ini
|
||||||
cat << end_of_content > ~/etc/php.d/memory_limit.ini
|
cat << end_of_content > ~/etc/php.d/memory_limit.ini
|
||||||
memory_limit=512M
|
memory_limit=512M
|
||||||
end_of_content
|
end_of_content
|
||||||
|
|
||||||
touch ~/etc/php.d/output_buffering.ini
|
touch ~/etc/php.d/output_buffering.ini
|
||||||
cat << end_of_content > ~/etc/php.d/output_buffering.ini
|
cat << end_of_content > ~/etc/php.d/output_buffering.ini
|
||||||
output_buffering=off
|
output_buffering=off
|
||||||
end_of_content
|
end_of_content
|
||||||
uberspace tools restart php
|
uberspace tools restart php
|
||||||
@@ -119,7 +115,7 @@ function setup_redis
|
|||||||
{
|
{
|
||||||
mkdir ~/.redis
|
mkdir ~/.redis
|
||||||
touch ~/.redis/conf
|
touch ~/.redis/conf
|
||||||
cat << end_of_content > ~/.redis/conf
|
cat << end_of_content > ~/.redis/conf
|
||||||
unixsocket /home/$USER/.redis/sock
|
unixsocket /home/$USER/.redis/sock
|
||||||
daemonize no
|
daemonize no
|
||||||
port 0
|
port 0
|
||||||
@@ -127,7 +123,7 @@ save ""
|
|||||||
end_of_content
|
end_of_content
|
||||||
|
|
||||||
touch ~/etc/services.d/redis.ini
|
touch ~/etc/services.d/redis.ini
|
||||||
cat << end_of_content > ~/etc/services.d/redis.ini
|
cat << end_of_content > ~/etc/services.d/redis.ini
|
||||||
[program:redis]
|
[program:redis]
|
||||||
command=redis-server %(ENV_HOME)s/.redis/conf
|
command=redis-server %(ENV_HOME)s/.redis/conf
|
||||||
directory=%(ENV_HOME)s/.redis
|
directory=%(ENV_HOME)s/.redis
|
||||||
@@ -173,7 +169,7 @@ end_of_content
|
|||||||
function install_nextcloud_updater
|
function install_nextcloud_updater
|
||||||
{
|
{
|
||||||
touch ~/bin/nextcloud-update
|
touch ~/bin/nextcloud-update
|
||||||
cat << end_of_content > ~/bin/nextcloud-update
|
cat << end_of_content > ~/bin/nextcloud-update
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
## Updater automatically works in maintenance:mode.
|
## Updater automatically works in maintenance:mode.
|
||||||
## Use the Uberspace backup system for files and database if you need to roll back.
|
## Use the Uberspace backup system for files and database if you need to roll back.
|
||||||
@@ -197,29 +193,42 @@ end_of_content
|
|||||||
chmod +x ~/bin/nextcloud-update
|
chmod +x ~/bin/nextcloud-update
|
||||||
}
|
}
|
||||||
|
|
||||||
function ask_if_fresh_uberspace
|
function yes-no_question
|
||||||
{
|
{
|
||||||
echo "This script tries to install the latest release of Nextcloud"
|
local question=$1
|
||||||
echo "but it is tested for Nextcloud 23 on Uberspace 7.12.0"
|
|
||||||
echo "and assumes a newly created uberspace with default settings."
|
|
||||||
echo "Do not run this script if you already use your Uberspace for other apps!"
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
read -r -p "Do you want to execute this installer for Nextcloud? (y/n) " ANSWER
|
read -r -p "$question (y/n) " ANSWER
|
||||||
case $ANSWER in
|
case $ANSWER in
|
||||||
[Yy]* | [Jj]* )
|
[Yy]* | [Jj]* )
|
||||||
install_nextcloud
|
return 0
|
||||||
break;;
|
;;
|
||||||
[Nn]* )
|
[Nn]* )
|
||||||
break;;
|
return 1
|
||||||
|
;;
|
||||||
* ) echo "Please answer yes or no. ";;
|
* ) echo "Please answer yes or no. ";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_critical_section { set -o pipefail -o errexit; }
|
||||||
|
function unset_critical_section { set +o pipefail +o errexit; }
|
||||||
|
|
||||||
function main
|
function main
|
||||||
{
|
{
|
||||||
ask_if_fresh_uberspace
|
set_critical_section
|
||||||
|
|
||||||
|
echo "This script tries to install the latest release of Nextcloud"
|
||||||
|
echo "but it is tested for Nextcloud 23 on Uberspace 7.12.0"
|
||||||
|
echo "and assumes a newly created Uberspace with default settings."
|
||||||
|
echo "Do not run this script if you already use your Uberspace for other apps!"
|
||||||
|
|
||||||
|
if yes-no_question "Do you want to execute this installer for Nextcloud?"
|
||||||
|
then install_nextcloud
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset_critical_section
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
exit $?
|
||||||
Reference in new issue
Block a user