Compare commits

..
13 Commits
7 changed files with 171 additions and 49 deletions

No files matched your search

+34
View File
@@ -56,3 +56,37 @@ Connect via SSH to your Uberspace an then run:
```sh ```sh
bash -c "$(wget -q -O - https://github.com/EV21/uberspace-helper/raw/main/gitea-installer.sh)" bash -c "$(wget -q -O - https://github.com/EV21/uberspace-helper/raw/main/gitea-installer.sh)"
``` ```
```console
[isabell@stardust ~]$ bash -c "$(wget -q -O - https://sh.ev21.de/uberspace/gitea-installer.sh)"
This script installs the latest release of Gitea
and assumes a newly created Uberspace with default settings.
The following files and directories will be created:
/home/isabell
├── bin
│ ├── [-rwxrw-r--] gitea (wrapper script)
│ └── [-rwxrw-r--] gitea-update
├── etc
│ ├── services.d
│ │ └── gitea.ini
│ └── ...
├── gitea
│ ├── custom
│ │ └── conf
│ │ └── app.ini (configuration file)
│ ├── data
│ └── [-rwxrw-r--] gitea (binary file)
└── ...
Do not run this script if you already use your Uberspace for other apps!
Do you want to execute this installer for Gitea? (y/n) y
Installing Gitea 1.18.4
Please set your Gitea login credentials.
Gitea admin user: AdminUserName
Your password input will not be visible.
Gitea admin password:
Gitea admin password confirmation:
... some magic moments later
You can now access your Gitea by directing your browser to:
https://isabell.uber.space
[isabell@stardust ~]$
```
+59 -29
View File
@@ -15,15 +15,11 @@ MYSQL_PASSWORD=${MYSQL_PASSWORD_STR:9}
function install_gitea function install_gitea
{ {
if [[ -n $USE_VERSION ]]
then GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/tags/v$USE_VERSION
fi
set_download_url
echo "Installing $APP_NAME $LATEST_VERSION"
echo "Please set your $APP_NAME login credentials." echo "Please set your $APP_NAME login credentials."
read -r -p "$APP_NAME admin user: " ADMIN_USER read -r -p "$APP_NAME admin user: " ADMIN_USER
read -r -p "$APP_NAME admin password: " ADMIN_PASS ask_for_password
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL" echo "Download $APP_NAME $INSTALL_VERSION"
curl --location --progress-bar --output "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
verify_file verify_file
mkdir --parents ~/gitea/custom/conf/ mkdir --parents ~/gitea/custom/conf/
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY" mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
@@ -35,25 +31,27 @@ function install_gitea
create_app_ini create_app_ini
mysql --verbose --execute="CREATE DATABASE ${USER}_gitea" mysql --verbose --execute="CREATE DATABASE ${USER}_gitea"
echo "The database initialisation may take a while ..." echo "The database initialisation may take a while ..."
$GITEA_BINARY migrate $GITEA_BINARY migrate 1>/dev/null
create_gitea_daemon_config create_gitea_daemon_config
supervisorctl reread supervisorctl reread
supervisorctl update supervisorctl update gitea
supervisorctl status supervisorctl status gitea
sleep 5 echo "waiting 30 seconds ..."
supervisorctl status sleep 30
supervisorctl status gitea
$GITEA_BINARY admin user create \ $GITEA_BINARY admin user create \
--username "${ADMIN_USER}" \ --username "${ADMIN_USER}" \
--password "${ADMIN_PASS}" \ --password "${ADMIN_PASS}" \
--email "${USER}"@uber.space \ --email "${USER}"@uber.space \
--admin \ --admin \
--config "/home/${USER}/gitea/custom/conf/app.ini" --config "/home/${USER}/gitea/custom/conf/app.ini" \
1>/dev/null
uberspace web backend set / --http --port $DEFAULT_PORT uberspace web backend set / --http --port $DEFAULT_PORT
uberspace web backend list uberspace web backend list
install_update_script install_update_script
echo "This is the file structure for this app" echo "This is the file structure for this app"
echo_tree echo_tree
printf "You can now access your $APP_NAME by directing you Browser to: \n https://%s.uber.space \n" "$USER" printf "You can now access your $APP_NAME by directing your browser to: \n https://%s.uber.space \n" "$USER"
} }
function uninstall_gitea function uninstall_gitea
@@ -70,11 +68,25 @@ function uninstall_gitea
rm ~/bin/gitea rm ~/bin/gitea
rm ~/bin/gitea-update rm ~/bin/gitea-update
supervisorctl reread supervisorctl reread
supervisorctl update supervisorctl update gitea
uberspace web backend set / --apache uberspace web backend set / --apache
set_critical_section set_critical_section
} }
function ask_for_password
{
echo "Note: Your password input will not be visible."
read -s -r -p "$APP_NAME admin password: " ADMIN_PASS
echo
read -s -r -p "$APP_NAME admin password confirmation: " ADMIN_PASS_CONFIRMATION
echo
while [ -z "$ADMIN_PASS" ] || [ "$ADMIN_PASS" != "$ADMIN_PASS_CONFIRMATION" ]
do
echo That was not correct, try again
ask_for_password
done
}
# This is only relevant for the uninstaller for broken old installations # This is only relevant for the uninstaller for broken old installations
function fix_stop_signal function fix_stop_signal
{ {
@@ -95,6 +107,9 @@ function process_parameters
use ) use )
shift shift
USE_VERSION="$1" USE_VERSION="$1"
if [[ -n $USE_VERSION ]]
then GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/tags/v$USE_VERSION
fi
shift shift
;; ;;
uninstall ) uninstall )
@@ -160,6 +175,7 @@ function create_app_ini
DOMAIN = $USER.uber.space DOMAIN = $USER.uber.space
ROOT_URL = https://%(DOMAIN)s ROOT_URL = https://%(DOMAIN)s
OFFLINE_MODE = true ; Disables use of CDN for static files and Gravatar for profile pictures. OFFLINE_MODE = true ; Disables use of CDN for static files and Gravatar for profile pictures.
LANDING_PAGE = explore ; possible options are [home, explore, organizations, login, custom like /org/repo or url]
LFS_START_SERVER = true ; Enables Git LFS support LFS_START_SERVER = true ; Enables Git LFS support
[database] [database]
@@ -174,6 +190,9 @@ MIN_PASSWORD_LENGTH = 8
PASSWORD_COMPLEXITY = lower PASSWORD_COMPLEXITY = lower
SECRET_KEY = $SECRET_KEY SECRET_KEY = $SECRET_KEY
[session]
COOKIE_SECURE = true
[service] [service]
DISABLE_REGISTRATION = true ; security option, only admins can create new users. DISABLE_REGISTRATION = true ; security option, only admins can create new users.
SHOW_REGISTRATION_BUTTON = false SHOW_REGISTRATION_BUTTON = false
@@ -183,9 +202,12 @@ DEFAULT_KEEP_EMAIL_PRIVATE = true
NO_REPLY_ADDRESS = noreply.${USER}.uber.space NO_REPLY_ADDRESS = noreply.${USER}.uber.space
[mailer] [mailer]
ENABLED = true ENABLED = true
MAILER_TYPE = sendmail PROTOCOL = sendmail
FROM = ${USER}@uber.space FROM = ${USER}@uber.space
[other]
SHOW_FOOTER_VERSION = false
end_of_content end_of_content
} }
@@ -200,11 +222,15 @@ autorestart=true
end_of_content end_of_content
} }
function set_download_url function set_install_version
{ {
curl --silent "$GITHUB_API_URL" > "$TMP_LOCATION"/github_api_response.json curl --silent "$GITHUB_API_URL" > "$TMP_LOCATION"/github_api_response.json
TAG_NAME=$(jq --raw-output '.tag_name' "$TMP_LOCATION"/github_api_response.json) TAG_NAME=$(jq --raw-output '.tag_name' "$TMP_LOCATION"/github_api_response.json)
LATEST_VERSION=${TAG_NAME:1} INSTALL_VERSION=${TAG_NAME:1}
}
function set_download_url
{
DOWNLOAD_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json | DOWNLOAD_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
grep --max-count=1 "linux-amd64") grep --max-count=1 "linux-amd64")
} }
@@ -256,12 +282,13 @@ GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
function do_update_procedure function do_update_procedure
{ {
curl --location --progress-bar --output "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
verify_file
$GITEA_BINARY manager flush-queues $GITEA_BINARY manager flush-queues
supervisorctl stop gitea supervisorctl stop gitea
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
verify_file
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY" mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
chmod u+x --verbose "$GITEA_BINARY" chmod u+x --verbose "$GITEA_BINARY"
echo "$APP_NAME service takes 30 seconds to start"
supervisorctl start gitea supervisorctl start gitea
supervisorctl status gitea supervisorctl status gitea
} }
@@ -312,9 +339,9 @@ function verify_file
fi fi
} }
# version_lower_than A B # is_version_lower_than A B
# returns whether A < B # returns whether A < B
function version_lower_than function is_version_lower_than
{ {
test "$(echo "$@" | # get all version arguments test "$(echo "$@" | # get all version arguments
tr " " "\n" | # replace `space` with `new line` tr " " "\n" | # replace `space` with `new line`
@@ -333,11 +360,11 @@ function fix_stop_signal
fi fi
} }
function update_available function is_update_available
{ {
set_local_version set_local_version
set_latest_version set_latest_version
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION" if is_version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
then return 0 then return 0
else return 1 else return 1
fi fi
@@ -347,7 +374,7 @@ function main
{ {
fix_stop_signal fix_stop_signal
if update_available if is_update_available
then then
echo "There is a new version available." echo "There is a new version available."
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION" echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
@@ -411,7 +438,10 @@ function main
set_critical_section set_critical_section
process_parameters "$@" process_parameters "$@"
echo "This script installs the latest release of $APP_NAME" set_install_version
set_download_url
echo "This script installs $APP_NAME $INSTALL_VERSION"
echo "and assumes a newly created Uberspace with default settings." echo "and assumes a newly created Uberspace with default settings."
echo "The following files and directories will be created:" echo "The following files and directories will be created:"
echo_tree echo_tree
@@ -421,7 +451,7 @@ function main
then echo "Port 3000 is already in use, abbort"; exit 1 then echo "Port 3000 is already in use, abbort"; exit 1
fi fi
if yes_no_question "Do you want to execute this installer for $APP_NAME?" if yes_no_question "Do you want to execute this installer for $APP_NAME $INSTALL_VERSION?"
then install_gitea then install_gitea
fi fi
+8 -7
View File
@@ -11,12 +11,13 @@ GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
function do_update_procedure function do_update_procedure
{ {
curl --location --progress-bar --output "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
verify_file
$GITEA_BINARY manager flush-queues $GITEA_BINARY manager flush-queues
supervisorctl stop gitea supervisorctl stop gitea
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
verify_file
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY" mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
chmod u+x --verbose "$GITEA_BINARY" chmod u+x --verbose "$GITEA_BINARY"
echo "$APP_NAME service takes 30 seconds to start"
supervisorctl start gitea supervisorctl start gitea
supervisorctl status gitea supervisorctl status gitea
} }
@@ -67,9 +68,9 @@ function verify_file
fi fi
} }
# version_lower_than A B # is_version_lower_than A B
# returns whether A < B # returns whether A < B
function version_lower_than function is_version_lower_than
{ {
test "$(echo "$@" | # get all version arguments test "$(echo "$@" | # get all version arguments
tr " " "\n" | # replace `space` with `new line` tr " " "\n" | # replace `space` with `new line`
@@ -88,11 +89,11 @@ function fix_stop_signal
fi fi
} }
function update_available function is_update_available
{ {
set_local_version set_local_version
set_latest_version set_latest_version
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION" if is_version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
then return 0 then return 0
else return 1 else return 1
fi fi
@@ -102,7 +103,7 @@ function main
{ {
fix_stop_signal fix_stop_signal
if update_available if is_update_available
then then
echo "There is a new version available." echo "There is a new version available."
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION" echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
+16 -8
View File
@@ -6,7 +6,8 @@ LOCAL_VERSION=$(jq --raw-output .version ~/hedgedoc/package.json)
LATEST_VERSION=$(curl --silent https://api.github.com/repos/$ORG/$REPO/releases/latest | LATEST_VERSION=$(curl --silent https://api.github.com/repos/$ORG/$REPO/releases/latest |
jq --raw-output .tag_name) jq --raw-output .tag_name)
function do_upgrade() { function do_upgrade
{
supervisorctl stop hedgedoc supervisorctl stop hedgedoc
echo "waiting 1 minute until all processes are stopped" echo "waiting 1 minute until all processes are stopped"
sleep 1m sleep 1m
@@ -26,7 +27,7 @@ function do_upgrade() {
rm --recursive ~/hedgedoc_"$LOCAL_VERSION" rm --recursive ~/hedgedoc_"$LOCAL_VERSION"
} }
function yes-no_question function yes_no_question
{ {
local question=$1 local question=$1
while true while true
@@ -45,9 +46,9 @@ function yes-no_question
done done
} }
## version_lower_than A B # is_version_lower_than A B
# returns whether A < B # returns whether A < B
function version_lower_than function is_version_lower_than
{ {
test "$(echo "$@" | test "$(echo "$@" |
tr " " "\n" | tr " " "\n" |
@@ -55,11 +56,17 @@ function version_lower_than
head --lines=1)" != "$1" head --lines=1)" != "$1"
} }
function is_update_available
{
if is_version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
then return 0
else return 1
fi
}
function main function main
{ {
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ] if is_update_available
then echo "Your HedgeDoc is already up to date."
elif version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
then then
echo "There is a new Version available of $APP_NAME" echo "There is a new Version available of $APP_NAME"
echo "The latest Version is $LATEST_VERSION" echo "The latest Version is $LATEST_VERSION"
@@ -68,9 +75,10 @@ function main
echo "Please read the release notes." echo "Please read the release notes."
echo "Also check if the upgrade instructions have changed." echo "Also check if the upgrade instructions have changed."
echo "Your instance might break." echo "Your instance might break."
if yes-no_question "Do you wish to proceed with the upgrade?" if yes_no_question "Do you wish to proceed with the upgrade?"
then do_upgrade then do_upgrade
fi fi
else echo "Your HedgeDoc is already up to date."
fi fi
} }
+50 -5
View File
@@ -1,12 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
APP_NAME=Nextcloud APP_NAME=Nextcloud
PHP_VERSION=8.2
PGP_KEY_FINGERPRINT='28806A878AE423A28372792ED75899B9A724937A'
function install_nextcloud function install_nextcloud
{ {
echo "Please set your Nextcloud login credentials." echo "Please set your Nextcloud login credentials."
read -r -p "Nextcloud admin user: " NEXTCLOUD_ADMIN_USER read -r -p "Nextcloud admin user: " NEXTCLOUD_ADMIN_USER
read -r -p "Nextcloud admin password: " NEXTCLOUD_ADMIN_PASS ask_for_password
trusted_domain="$USER.uber.space" trusted_domain="$USER.uber.space"
setup_php setup_php
# simply get the first password string from ~/.my.cnf # simply get the first password string from ~/.my.cnf
@@ -28,7 +31,6 @@ function install_nextcloud
curl --silent --remote-name https://download.nextcloud.com/server/releases/"$signature_file" curl --silent --remote-name https://download.nextcloud.com/server/releases/"$signature_file"
curl --silent --remote-name https://nextcloud.com/nextcloud.asc curl --silent --remote-name https://nextcloud.com/nextcloud.asc
gpg --import nextcloud.asc gpg --import nextcloud.asc
PGP_KEY_FINGERPRINT='28806A878AE423A28372792ED75899B9A724937A'
#gpg --keyserver pgp.mit.edu --recv-keys $PGP_KEY_FINGERPRINT #gpg --keyserver pgp.mit.edu --recv-keys $PGP_KEY_FINGERPRINT
echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
if ! gpg --verify "$signature_file" "$release_archive" if ! gpg --verify "$signature_file" "$release_archive"
@@ -89,6 +91,7 @@ function uninstall_nextcloud
fi fi
if test -f ~/etc/services.d/notify_push.ini if test -f ~/etc/services.d/notify_push.ini
then then
uberspace web backend del /push
supervisorctl stop notify_push supervisorctl stop notify_push
rm ~/etc/services.d/notify_push.ini rm ~/etc/services.d/notify_push.ini
supervisorctl reread supervisorctl reread
@@ -105,12 +108,27 @@ function uninstall_nextcloud
rm -r ~/html/* ~/html/.htaccess ~/html/.user.ini ~/_nextcloud_completion rm -r ~/html/* ~/html/.htaccess ~/html/.user.ini ~/_nextcloud_completion
mysql --verbose --execute="DROP DATABASE ${USER}_nextcloud" mysql --verbose --execute="DROP DATABASE ${USER}_nextcloud"
rm ~/bin/ncc ~/bin/nextcloud-update rm ~/bin/ncc ~/bin/nextcloud-update
sed --in-place '/_nextcloud_completion/d' ~/.bash_profile
unlink ~/bin/notify_push unlink ~/bin/notify_push
unlink ~/logs/nextcloud.log unlink ~/logs/nextcloud.log
unlink ~/logs/nextcloud-updater.log unlink ~/logs/nextcloud-updater.log
set_critical_section set_critical_section
} }
function ask_for_password
{
echo "Note: Your password input will not be visible."
read -s -r -p "$APP_NAME admin password: " NEXTCLOUD_ADMIN_PASS
echo
read -s -r -p "$APP_NAME admin password confirmation: " ADMIN_PASS_CONFIRMATION
echo
while [ -z "$NEXTCLOUD_ADMIN_PASS" ] || [ "$NEXTCLOUD_ADMIN_PASS" != "$ADMIN_PASS_CONFIRMATION" ]
do
echo That was not correct, try again
ask_for_password
done
}
function process_parameters function process_parameters
{ {
while test $# -gt 0 while test $# -gt 0
@@ -148,7 +166,7 @@ function get_version_name
function setup_php function setup_php
{ {
echo "Applying relevant PHP settings for Nextcloud" echo "Applying relevant PHP settings for Nextcloud"
uberspace tools version use php 8.1 uberspace tools version use php $PHP_VERSION
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
@@ -223,7 +241,10 @@ end_of_content
supervisorctl update supervisorctl update
supervisorctl status supervisorctl status
uberspace web backend set /push --http --port 7867 uberspace web backend set /push --http --port 7867
uberspace web backend list local fail_counter=0
while (uberspace web backend list | grep "/push http:7867 => NOT OK") && test $fail_counter -lt 5
do echo 'wait another 5 seconds for notify service'; sleep 5; ((fail_counter++))
done
local trusted_proxy local trusted_proxy
trusted_proxy=$(ip route | trusted_proxy=$(ip route |
tail --lines 1 | ## filter last line tail --lines 1 | ## filter last line
@@ -272,6 +293,8 @@ ncc db:add-missing-indices --no-interaction
ncc db:convert-filecache-bigint --no-interaction ncc db:convert-filecache-bigint --no-interaction
ncc app:update --all ncc app:update --all
## App updates may require additional steps to be done by the `upgrade` command
ncc upgrade
/usr/sbin/restorecon -R $APP_LOCATION /usr/sbin/restorecon -R $APP_LOCATION
if test -f ~/etc/services.d/notify_push.ini if test -f ~/etc/services.d/notify_push.ini
@@ -299,6 +322,27 @@ function yes_no_question
done done
} }
function echo_tree
{
cat << end_of_content
/home/$USER
├── _nextcloud_completion
├── bin
│ ├── ncc (wrapper shortcut for ~/html/occ)
│ ├── nextcloud-update
│ └── notify_push -> /home/$USER/html/apps/notify_push/bin/x86_64/notify_push
├── nextcloud_data
│ └── >> user files, etc. <<
├── html -> /var/www/virtual/$USER/html
│ └── >> Nextcloud installation <<
├── logs
│ ├── nextcloud-cron.log
│ ├── nextcloud-updater.log -> /home/$USER/nextcloud_data/updater.log
│ └── nextcloud.log -> /home/$USER/nextcloud_data/nextcloud.log
└── ...
end_of_content
}
function set_critical_section { set -o pipefail -o errexit; } function set_critical_section { set -o pipefail -o errexit; }
function unset_critical_section { set +o pipefail +o errexit; } function unset_critical_section { set +o pipefail +o errexit; }
@@ -316,8 +360,9 @@ function main
echo "This script installs the latest release of $APP_NAME" echo "This script installs the latest release of $APP_NAME"
echo "and assumes a newly created Uberspace with default settings." echo "and assumes a newly created Uberspace with default settings."
fi fi
echo 'This will be the basic file structure'
echo_tree
echo "Do not run this script if you already use your Uberspace for other apps!" 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 $APP_NAME?" if yes_no_question "Do you want to execute this installer for $APP_NAME?"
then install_nextcloud then install_nextcloud
fi fi
+2
View File
@@ -98,6 +98,8 @@ function do_update_procedure
ncc db:add-missing-indices --no-interaction ncc db:add-missing-indices --no-interaction
ncc db:convert-filecache-bigint --no-interaction ncc db:convert-filecache-bigint --no-interaction
ncc app:update --all ncc app:update --all
## App updates may require additional steps to be done by the `upgrade` command
ncc upgrade
/usr/sbin/restorecon -R "$APP_LOCATION" /usr/sbin/restorecon -R "$APP_LOCATION"
if test -f ~/etc/services.d/notify_push.ini if test -f ~/etc/services.d/notify_push.ini
then supervisorctl restart notify_push then supervisorctl restart notify_push
+2
View File
@@ -21,6 +21,8 @@ ncc db:add-missing-indices --no-interaction
ncc db:convert-filecache-bigint --no-interaction ncc db:convert-filecache-bigint --no-interaction
ncc app:update --all ncc app:update --all
## App updates may require additional steps to be done by the `upgrade` command
ncc upgrade
/usr/sbin/restorecon -R $APP_LOCATION /usr/sbin/restorecon -R $APP_LOCATION
if test -f ~/etc/services.d/notify_push.ini if test -f ~/etc/services.d/notify_push.ini