mirror of
https://github.com/EV21/uberspace-helper.git
synced 2026-10-08 04:43:18 +02:00
Compare commits
1
Commits
f693a1517f
..
zsh
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54a418e6be
|
No files matched your search
@@ -4,41 +4,31 @@
|
|||||||
- [☕ Gitea Installer](#gitea-installer-script)
|
- [☕ Gitea Installer](#gitea-installer-script)
|
||||||
|
|
||||||
## Nextcloud installer script
|
## Nextcloud installer script
|
||||||
|
|
||||||
The lab guide is condensed into a script so Nextcloud can be installed in less than 3 minutes by executing only one command and setting the admin user credentials.
|
The lab guide is condensed into a script so Nextcloud can be installed in less than 3 minutes by executing only one command and setting the admin user credentials.
|
||||||
|
|
||||||
The following components will be set up and installed automatically:
|
The following components will be set up and installed automatically:
|
||||||
|
|
||||||
- php settings
|
* php settings
|
||||||
- sendmail email settings
|
* sendmail email settings
|
||||||
- cronjob
|
* cronjob
|
||||||
- prettier URLs without index.php
|
* prettier URLs without index.php
|
||||||
- Memcaching with redis and APCu
|
* Memcaching with redis and APCu
|
||||||
- Client Push (notify_push)
|
* Client Push (notify_push)
|
||||||
- `nextcloud-update` script
|
* `nextcloud-update` script
|
||||||
- the default phone region will be set to `DE`, you may change it after the installation to a different setting
|
* the default phone region will be set to `DE`, you may change it after the installation to a different setting
|
||||||
- `ncc` wrapper command for `occ` with bash completion
|
|
||||||
|
|
||||||
Connect via SSH to your Uberspace an then run:
|
Connect via SSH to your Uberspace an then run:
|
||||||
|
|
||||||
```sh
|
|
||||||
bash -c "$(wget -q -O - https://github.com/EV21/uberspace-helper/raw/main/nextcloud-installer.sh)"
|
|
||||||
```
|
```
|
||||||
|
bash -c "$(wget -q -O - https://github.com/EV21/uberspace-helper/raw/main/nextcloud-installer.sh)"
|
||||||
alternatively something shorter:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
bash -c "$(wget -q -O - https://sh.ev21.de/uberspace/nextcloud-installer.sh)"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
<!-- markdownlint-disable-next-line MD034 -->
|
|
||||||
https://user-images.githubusercontent.com/8345730/154812905-970c649d-4360-4846-961c-1d8363d662f2.mp4
|
https://user-images.githubusercontent.com/8345730/154812905-970c649d-4360-4846-961c-1d8363d662f2.mp4
|
||||||
|
|
||||||
<!-- unused
|
|
||||||
[nextcloud-installer-gif-demo]: ./presentation/uberspace-nextcloud-installer.gif
|
[nextcloud-installer-gif-demo]: ./presentation/uberspace-nextcloud-installer.gif
|
||||||
-->
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -53,40 +43,6 @@ The following steps will be done automatically:
|
|||||||
|
|
||||||
Connect via SSH to your Uberspace an then run:
|
Connect via SSH to your Uberspace an then run:
|
||||||
|
|
||||||
```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 ~]$
|
|
||||||
```
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
|
|
||||||
## source this file to enable bash autocompletion for the `uberspace` command
|
|
||||||
## example: 👇
|
|
||||||
## source ~/_uberspace_completion
|
|
||||||
## usage: type uberspace<space><tab><tab>
|
|
||||||
## the result should be an output of `mail port takeout tools web`
|
|
||||||
##
|
|
||||||
## This is inspired by Zero Piraeus' answer on stackoverflow, thanks. 👍🚀
|
|
||||||
## https://stackoverflow.com/questions/17879322/how-do-i-autocomplete-nested-multi-level-subcommands/17881946#17881946
|
|
||||||
|
|
||||||
_uberspace()
|
|
||||||
{
|
|
||||||
local cur prev
|
|
||||||
|
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
||||||
|
|
||||||
case ${COMP_CWORD} in
|
|
||||||
1)
|
|
||||||
COMPREPLY=($(compgen -W "mail port takeout tools web" -- ${cur}))
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
case ${prev} in
|
|
||||||
mail)
|
|
||||||
COMPREPLY=($(compgen -W "catchall domain spamfolder user" -- ${cur}))
|
|
||||||
;;
|
|
||||||
port)
|
|
||||||
COMPREPLY=($(compgen -W "add del list" -- ${cur}))
|
|
||||||
;;
|
|
||||||
# takeout)
|
|
||||||
## Beta? - As I have not used this tool I don't know if this is correct
|
|
||||||
# COMPREPLY=($(compgen -W "takeout takein items" -- ${cur}))
|
|
||||||
# ;;
|
|
||||||
tools)
|
|
||||||
COMPREPLY=($(compgen -W "restart version" -- ${cur}))
|
|
||||||
;;
|
|
||||||
web)
|
|
||||||
COMPREPLY=($(compgen -W "backend domain errorpage header log traffic" -- ${cur}))
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
3)
|
|
||||||
case ${prev} in
|
|
||||||
catchall)
|
|
||||||
COMPREPLY=($(compgen -W "del set status" -- ${cur}))
|
|
||||||
;;
|
|
||||||
domain)
|
|
||||||
COMPREPLY=($(compgen -W "add del list" -- ${cur}))
|
|
||||||
;;
|
|
||||||
spamfolder | errorpage | log)
|
|
||||||
COMPREPLY=($(compgen -W "disable enable status" -- ${cur}))
|
|
||||||
;;
|
|
||||||
user)
|
|
||||||
COMPREPLY=($(compgen -W "add del forward list password" -- ${cur}))
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
COMPREPLY=($(compgen -W "php" -- ${cur}))
|
|
||||||
;;
|
|
||||||
version)
|
|
||||||
COMPREPLY=($(compgen -W "list show use" -- ${cur}))
|
|
||||||
;;
|
|
||||||
backend)
|
|
||||||
COMPREPLY=($(compgen -W "del list set" -- ${cur}))
|
|
||||||
;;
|
|
||||||
header)
|
|
||||||
COMPREPLY=($(compgen -W "del list set suppress" -- ${cur}))
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
4)
|
|
||||||
case ${prev} in
|
|
||||||
show | use)
|
|
||||||
COMPREPLY=($(compgen -W "couchdb erlang mongodb node php postgresql prolog ruby rust" -- ${cur}))
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
COMPREPLY=()
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -F _uberspace uberspace
|
|
||||||
+82
-218
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
APP_NAME=Gitea
|
APP_NAME=Gitea
|
||||||
DEFAULT_PORT=3000
|
DEFAULT_PORT=3000
|
||||||
GITEA_BINARY=$HOME/gitea/gitea
|
GITEA_BIN_LOCATION=$HOME/gitea/gitea
|
||||||
TMP_LOCATION=$HOME/tmp
|
TMP_LOCATION=$HOME/tmp
|
||||||
PGP_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
GPG_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||||
ORG=go-gitea # Organisation or GitHub user
|
ORG=go-gitea # Organisation or GitHub user
|
||||||
REPO=gitea
|
REPO=gitea
|
||||||
GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
|
GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
|
||||||
@@ -15,116 +15,40 @@ MYSQL_PASSWORD=${MYSQL_PASSWORD_STR:9}
|
|||||||
|
|
||||||
function install_gitea
|
function install_gitea
|
||||||
{
|
{
|
||||||
|
get_latest_version
|
||||||
|
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
|
||||||
ask_for_password
|
read -r -p "$APP_NAME admin password: " ADMIN_PASS
|
||||||
echo "Download $APP_NAME $INSTALL_VERSION"
|
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||||
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_BIN_LOCATION"
|
||||||
chmod u+x --verbose "$GITEA_BINARY"
|
chmod u+x --verbose "$GITEA_BIN_LOCATION"
|
||||||
#ln --symbolic --verbose "$GITEA_BINARY" ~/bin/gitea
|
#ln --symbolic --verbose "$GITEA_BIN_LOCATION" ~/bin/gitea
|
||||||
## gitea does not recognize its real path, maybe use a wrapper for this
|
## gitea does not recognize its real path, maybe use a wrapper for this
|
||||||
install_gitea_wrapper
|
install_gitea_wrapper
|
||||||
ln --symbolic --verbose ~/.ssh ~/gitea/.ssh
|
ln --symbolic --verbose ~/.ssh ~/gitea/.ssh
|
||||||
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 1>/dev/null
|
$GITEA_BIN_LOCATION migrate
|
||||||
create_gitea_daemon_config
|
create_gitea_daemon_config
|
||||||
supervisorctl reread
|
supervisorctl reread
|
||||||
supervisorctl update gitea
|
supervisorctl update
|
||||||
supervisorctl status gitea
|
supervisorctl status
|
||||||
echo "waiting 30 seconds ..."
|
sleep 5
|
||||||
sleep 30
|
supervisorctl status
|
||||||
supervisorctl status gitea
|
$GITEA_BIN_LOCATION 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"
|
printf "You can now access your $APP_NAME by directing you Browser to: \n https://%s.uber.space \n" "$USER"
|
||||||
echo_tree
|
|
||||||
printf "You can now access your $APP_NAME by directing your browser to: \n https://%s.uber.space \n" "$USER"
|
|
||||||
}
|
|
||||||
|
|
||||||
function uninstall_gitea
|
|
||||||
{
|
|
||||||
# If some files do not exist there may be some errors
|
|
||||||
unset_critical_section
|
|
||||||
fix_stop_signal
|
|
||||||
$GITEA_BINARY manager flush-queues
|
|
||||||
supervisorctl stop gitea
|
|
||||||
sleep 30
|
|
||||||
mysql --verbose --execute="DROP DATABASE ${USER}_gitea"
|
|
||||||
rm ~/etc/services.d/gitea.ini
|
|
||||||
rm -r ~/gitea
|
|
||||||
rm ~/bin/gitea
|
|
||||||
rm ~/bin/gitea-update
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update gitea
|
|
||||||
uberspace web backend set / --apache
|
|
||||||
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
|
|
||||||
function fix_stop_signal
|
|
||||||
{
|
|
||||||
if (grep --quiet HUP "$HOME"/etc/services.d/gitea.ini)
|
|
||||||
then
|
|
||||||
sed --in-place '/HUP/d' "$HOME"/etc/services.d/gitea.ini
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function process_parameters
|
|
||||||
{
|
|
||||||
while test $# -gt 0
|
|
||||||
do
|
|
||||||
local next_parameter=$1
|
|
||||||
case $next_parameter in
|
|
||||||
use )
|
|
||||||
shift
|
|
||||||
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
|
|
||||||
;;
|
|
||||||
uninstall )
|
|
||||||
echo "This command tries to revert the $APP_NAME installation, it will delete all of its scripts, service config, ~/gitea directory with all contents and drop the database"
|
|
||||||
if yes_no_question "Do you really want to do this?"
|
|
||||||
then uninstall_gitea
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
echo "$1 can not be processed, exiting script"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_gitea_wrapper
|
function install_gitea_wrapper
|
||||||
@@ -137,7 +61,7 @@ function install_gitea_wrapper
|
|||||||
export GITEA_WORK_DIR=$HOME/gitea
|
export GITEA_WORK_DIR=$HOME/gitea
|
||||||
|
|
||||||
FIRST_PARAMETER="$1"
|
FIRST_PARAMETER="$1"
|
||||||
GITEA_BINARY=$HOME/gitea/gitea
|
GITEA_BIN_LOCATION=$HOME/gitea/gitea
|
||||||
|
|
||||||
case $FIRST_PARAMETER in
|
case $FIRST_PARAMETER in
|
||||||
start | stop | restart | status )
|
start | stop | restart | status )
|
||||||
@@ -156,12 +80,12 @@ case $FIRST_PARAMETER in
|
|||||||
## this command creates a backup zip file with db, repos, config, log, data
|
## this command creates a backup zip file with db, repos, config, log, data
|
||||||
## restoring the backup is more difficult
|
## restoring the backup is more difficult
|
||||||
## read: https://docs.gitea.io/en-us/backup-and-restore/#restore-command-restore
|
## read: https://docs.gitea.io/en-us/backup-and-restore/#restore-command-restore
|
||||||
$GITEA_BINARY dump --tempdir $HOME/tmp
|
$GITEA_BIN_LOCATION dump --tempdir $HOME/tmp
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
$GITEA_BINARY "$@"
|
$GITEA_BIN_LOCATION "$@"
|
||||||
exit $?
|
exit $?
|
||||||
end_of_content
|
end_of_content
|
||||||
chmod u+x --verbose ~/bin/gitea
|
chmod u+x --verbose ~/bin/gitea
|
||||||
@@ -169,13 +93,12 @@ end_of_content
|
|||||||
|
|
||||||
function create_app_ini
|
function create_app_ini
|
||||||
{
|
{
|
||||||
SECRET_KEY=$($GITEA_BINARY generate secret SECRET_KEY)
|
SECRET_KEY=$($GITEA_BIN_LOCATION generate secret SECRET_KEY)
|
||||||
cat << end_of_content > ~/gitea/custom/conf/app.ini
|
cat << end_of_content > ~/gitea/custom/conf/app.ini
|
||||||
[server]
|
[server]
|
||||||
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]
|
||||||
@@ -190,9 +113,6 @@ 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
|
||||||
@@ -206,8 +126,8 @@ ENABLED = true
|
|||||||
MAILER_TYPE = sendmail
|
MAILER_TYPE = sendmail
|
||||||
FROM = ${USER}@uber.space
|
FROM = ${USER}@uber.space
|
||||||
|
|
||||||
[other]
|
[repository]
|
||||||
SHOW_FOOTER_VERSION = false
|
DEFAULT_BRANCH = main
|
||||||
end_of_content
|
end_of_content
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,26 +136,24 @@ function create_gitea_daemon_config
|
|||||||
cat << end_of_content > ~/etc/services.d/gitea.ini
|
cat << end_of_content > ~/etc/services.d/gitea.ini
|
||||||
[program:gitea]
|
[program:gitea]
|
||||||
directory=%(ENV_HOME)s/gitea
|
directory=%(ENV_HOME)s/gitea
|
||||||
command=%(ENV_HOME)s/gitea/gitea web
|
command=gitea web
|
||||||
startsecs=30
|
startsecs=30
|
||||||
|
stopsignal=HUP
|
||||||
autorestart=true
|
autorestart=true
|
||||||
end_of_content
|
end_of_content
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_install_version
|
function get_latest_version
|
||||||
{
|
{
|
||||||
curl --silent "$GITHUB_API_URL" > "$TMP_LOCATION"/github_api_response.json
|
|
||||||
TAG_NAME=$(jq --raw-output '.tag_name' "$TMP_LOCATION"/github_api_response.json)
|
|
||||||
INSTALL_VERSION=${TAG_NAME:1}
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_download_url
|
curl --silent $GITHUB_API_URL > "$TMP_LOCATION"/github_api_response.json
|
||||||
{
|
TAG_NAME=$(jq --raw-output '.tag_name' "$TMP_LOCATION"/github_api_response.json)
|
||||||
|
LATEST_VERSION=${TAG_NAME:1}
|
||||||
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_signature_file
|
function get_signature_file
|
||||||
{
|
{
|
||||||
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
||||||
grep "linux-amd64.asc")
|
grep "linux-amd64.asc")
|
||||||
@@ -245,19 +163,18 @@ function download_signature_file
|
|||||||
|
|
||||||
function verify_file
|
function verify_file
|
||||||
{
|
{
|
||||||
download_signature_file
|
get_signature_file
|
||||||
|
|
||||||
## downloading public key if it does NOT already exist OR if it is expired
|
## downloading public key if it does not already exist
|
||||||
if ! (gpg --fingerprint $PGP_KEY_FINGERPRINT) ||
|
if ! gpg --fingerprint $GPG_KEY_FINGERPRINT
|
||||||
(gpg --fingerprint $PGP_KEY_FINGERPRINT | grep expired)
|
|
||||||
then
|
then
|
||||||
## currently the key download via gpg does not work on Uberspace
|
## currently the key download via gpg does not work on Uberspace
|
||||||
#gpg --keyserver keys.openpgp.org --recv $PGP_KEY_FINGERPRINT
|
#gpg --keyserver keys.openpgp.org --recv $GPG_KEY_FINGERPRINT
|
||||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$PGP_KEY_FINGERPRINT | gpg --import
|
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$GPG_KEY_FINGERPRINT | gpg --import
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! gpg --export-ownertrust | grep --quiet $PGP_KEY_FINGERPRINT:6:
|
if ! gpg --export-ownertrust | grep --quiet $GPG_KEY_FINGERPRINT:6:
|
||||||
then echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
then echo "$GPG_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if gpg --verify "$TMP_LOCATION"/gitea.asc "$TMP_LOCATION"/gitea
|
if gpg --verify "$TMP_LOCATION"/gitea.asc "$TMP_LOCATION"/gitea
|
||||||
@@ -272,9 +189,9 @@ function install_update_script
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
APP_NAME=Gitea
|
APP_NAME=Gitea
|
||||||
GITEA_BINARY=$HOME/gitea/gitea
|
GITEA_LOCATION=$HOME/gitea/gitea
|
||||||
TMP_LOCATION=$HOME/tmp
|
TMP_LOCATION=$HOME/tmp
|
||||||
PGP_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
GPG_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||||
|
|
||||||
ORG=go-gitea # Organisation or GitHub user
|
ORG=go-gitea # Organisation or GitHub user
|
||||||
REPO=gitea
|
REPO=gitea
|
||||||
@@ -282,137 +199,94 @@ 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"
|
$GITEA_LOCATION manager flush-queues
|
||||||
verify_file
|
|
||||||
$GITEA_BINARY manager flush-queues
|
|
||||||
supervisorctl stop gitea
|
supervisorctl stop gitea
|
||||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
|
wget --quiet --progress=bar:force --output-document $TMP_LOCATION/gitea "$DOWNLOAD_URL"
|
||||||
chmod u+x --verbose "$GITEA_BINARY"
|
verify_file
|
||||||
echo "$APP_NAME service takes 30 seconds to start"
|
supervisorctl stop gitea
|
||||||
|
mv --verbose $TMP_LOCATION/gitea "$GITEA_LOCATION"
|
||||||
|
chmod u+x --verbose "$GITEA_LOCATION"
|
||||||
supervisorctl start gitea
|
supervisorctl start gitea
|
||||||
supervisorctl status gitea
|
supervisorctl status gitea
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_local_version
|
function get_local_version
|
||||||
{
|
{
|
||||||
LOCAL_VERSION=$($GITEA_BINARY --version |
|
LOCAL_VERSION=$($GITEA_LOCATION --version |
|
||||||
awk '{print $3}')
|
awk '{print $3}')
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_latest_version
|
function get_latest_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}
|
LATEST_VERSION=${TAG_NAME:1}
|
||||||
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_signature_file
|
function get_signature_file
|
||||||
{
|
{
|
||||||
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' $TMP_LOCATION/github_api_response.json |
|
||||||
grep "linux-amd64.asc")
|
grep "linux-amd64.asc")
|
||||||
rm "$TMP_LOCATION"/github_api_response.json
|
rm $TMP_LOCATION/github_api_response.json
|
||||||
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea.asc "$SIGNATURE_FILE_URL"
|
wget --quiet --progress=bar:force --output-document $TMP_LOCATION/gitea.asc "$SIGNATURE_FILE_URL"
|
||||||
}
|
}
|
||||||
|
|
||||||
function verify_file
|
function verify_file
|
||||||
{
|
{
|
||||||
download_signature_file
|
get_signature_file
|
||||||
|
|
||||||
## downloading public key if it does NOT already exist OR if it is expired
|
## downloading public key if it does not already exist
|
||||||
if ! gpg --fingerprint $PGP_KEY_FINGERPRINT ||
|
if ! gpg --fingerprint $GPG_KEY_FINGERPRINT
|
||||||
(gpg --fingerprint $PGP_KEY_FINGERPRINT | grep expired)
|
|
||||||
then
|
then
|
||||||
## currently the key download via gpg does not work on Uberspace
|
## currently the key download via gpg does not work on Uberspace
|
||||||
#gpg --keyserver keys.openpgp.org --recv $PGP_KEY_FINGERPRINT
|
#gpg --keyserver keys.openpgp.org --recv $GPG_KEY_FINGERPRINT
|
||||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$PGP_KEY_FINGERPRINT | gpg --import
|
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$GPG_KEY_FINGERPRINT | gpg --import
|
||||||
|
echo "$GPG_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! gpg --export-ownertrust | grep --quiet $PGP_KEY_FINGERPRINT:6:
|
if gpg --verify $TMP_LOCATION/gitea.asc $TMP_LOCATION/gitea
|
||||||
then echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
then rm $TMP_LOCATION/gitea.asc; return 0
|
||||||
fi
|
|
||||||
|
|
||||||
if gpg --verify "$TMP_LOCATION"/gitea.asc "$TMP_LOCATION"/gitea
|
|
||||||
then rm "$TMP_LOCATION"/gitea.asc; return 0
|
|
||||||
else echo "gpg verification results in a BAD signature"; exit 1
|
else echo "gpg verification results in a BAD signature"; exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# version_lower_than A B
|
## this is a helper function to compare two versions as a "lower than" operator
|
||||||
# returns whether A < B
|
function version_lt
|
||||||
function is_version_lower_than
|
|
||||||
{
|
{
|
||||||
test "$(echo "$@" | # get all version arguments
|
test "$(echo "$@" |
|
||||||
tr " " "\n" | # replace `space` with `new line`
|
tr " " "n" |
|
||||||
sed '/alpha/d; /beta/d; /rc/d' | # remove pre-release versions (version-sort interprets suffixes as patch versions)
|
sort --version-sort --reverse |
|
||||||
sort --version-sort --reverse | # latest version will be sorted to line 1
|
head --lines=1)" != "$1"
|
||||||
head --lines=1)" != "$1" # filter line 1 and compare it to A
|
|
||||||
}
|
|
||||||
|
|
||||||
function fix_stop_signal
|
|
||||||
{
|
|
||||||
if (grep --quiet HUP "$HOME"/etc/services.d/gitea.ini)
|
|
||||||
then
|
|
||||||
sed --in-place '/HUP/d' "$HOME"/etc/services.d/gitea.ini
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_update_available
|
|
||||||
{
|
|
||||||
set_local_version
|
|
||||||
set_latest_version
|
|
||||||
if is_version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function main
|
function main
|
||||||
{
|
{
|
||||||
fix_stop_signal
|
get_local_version
|
||||||
|
get_latest_version
|
||||||
|
|
||||||
if is_update_available
|
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||||
|
then
|
||||||
|
echo "Your $APP_NAME is already up to date."
|
||||||
|
echo "You are running $APP_NAME $LOCAL_VERSION"
|
||||||
|
else
|
||||||
|
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||||
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"
|
||||||
do_update_procedure
|
do_update_procedure
|
||||||
else
|
fi
|
||||||
echo "Your $APP_NAME is already up to date."
|
|
||||||
echo "You are running $APP_NAME $LOCAL_VERSION"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "${@}"
|
||||||
exit $?
|
exit $?
|
||||||
end_of_content
|
end_of_content
|
||||||
chmod u+x --verbose ~/bin/gitea-update
|
chmod u+x --verbose ~/bin/gitea-update
|
||||||
}
|
}
|
||||||
|
|
||||||
function echo_tree
|
function yes-no_question
|
||||||
{
|
|
||||||
cat << end_of_content
|
|
||||||
/home/$USER
|
|
||||||
├── 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)
|
|
||||||
└── ...
|
|
||||||
end_of_content
|
|
||||||
}
|
|
||||||
|
|
||||||
function yes_no_question
|
|
||||||
{
|
{
|
||||||
local question=$1
|
local question=$1
|
||||||
while true
|
while true
|
||||||
@@ -436,22 +310,12 @@ function unset_critical_section { set +o pipefail +o errexit; }
|
|||||||
function main
|
function main
|
||||||
{
|
{
|
||||||
set_critical_section
|
set_critical_section
|
||||||
process_parameters "$@"
|
|
||||||
|
|
||||||
set_install_version
|
echo "This script installs the latest release of $APP_NAME"
|
||||||
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_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 (lsof -nP -iTCP:3000 -sTCP:LISTEN)
|
if yes-no_question "Do you want to execute this installer for $APP_NAME?"
|
||||||
then echo "Port 3000 is already in use, abbort"; exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if yes_no_question "Do you want to execute this installer for $APP_NAME $INSTALL_VERSION?"
|
|
||||||
then install_gitea
|
then install_gitea
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
+35
-53
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
APP_NAME=Gitea
|
APP_NAME=Gitea
|
||||||
GITEA_BINARY=$HOME/gitea/gitea
|
GITEA_LOCATION=$HOME/gitea/gitea
|
||||||
TMP_LOCATION=$HOME/tmp
|
TMP_LOCATION=$HOME/tmp
|
||||||
PGP_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
GPG_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||||
|
|
||||||
ORG=go-gitea # Organisation or GitHub user
|
ORG=go-gitea # Organisation or GitHub user
|
||||||
REPO=gitea
|
REPO=gitea
|
||||||
@@ -11,24 +11,24 @@ 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"
|
$GITEA_LOCATION manager flush-queues
|
||||||
verify_file
|
|
||||||
$GITEA_BINARY manager flush-queues
|
|
||||||
supervisorctl stop gitea
|
supervisorctl stop gitea
|
||||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
|
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||||
chmod u+x --verbose "$GITEA_BINARY"
|
verify_file
|
||||||
echo "$APP_NAME service takes 30 seconds to start"
|
supervisorctl stop gitea
|
||||||
|
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_LOCATION"
|
||||||
|
chmod u+x --verbose "$GITEA_LOCATION"
|
||||||
supervisorctl start gitea
|
supervisorctl start gitea
|
||||||
supervisorctl status gitea
|
supervisorctl status gitea
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_local_version
|
function get_local_version
|
||||||
{
|
{
|
||||||
LOCAL_VERSION=$($GITEA_BINARY --version |
|
LOCAL_VERSION=$($GITEA_LOCATION --version |
|
||||||
awk '{print $3}')
|
awk '{print $3}')
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_latest_version
|
function get_latest_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)
|
||||||
@@ -37,7 +37,7 @@ function set_latest_version
|
|||||||
grep --max-count=1 "linux-amd64")
|
grep --max-count=1 "linux-amd64")
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_signature_file
|
function get_signature_file
|
||||||
{
|
{
|
||||||
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
||||||
grep "linux-amd64.asc")
|
grep "linux-amd64.asc")
|
||||||
@@ -47,70 +47,52 @@ function download_signature_file
|
|||||||
|
|
||||||
function verify_file
|
function verify_file
|
||||||
{
|
{
|
||||||
download_signature_file
|
get_signature_file
|
||||||
|
|
||||||
## downloading public key if it does NOT already exist OR if it is expired
|
## downloading public key if it does not already exist
|
||||||
if ! gpg --fingerprint $PGP_KEY_FINGERPRINT ||
|
if ! gpg --fingerprint $GPG_KEY_FINGERPRINT
|
||||||
(gpg --fingerprint $PGP_KEY_FINGERPRINT | grep expired)
|
|
||||||
then
|
then
|
||||||
## currently the key download via gpg does not work on Uberspace
|
## currently the key download via gpg does not work on Uberspace
|
||||||
#gpg --keyserver keys.openpgp.org --recv $PGP_KEY_FINGERPRINT
|
#gpg --keyserver keys.openpgp.org --recv $GPG_KEY_FINGERPRINT
|
||||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$PGP_KEY_FINGERPRINT | gpg --import
|
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$GPG_KEY_FINGERPRINT | gpg --import
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! gpg --export-ownertrust | grep --quiet $PGP_KEY_FINGERPRINT:6:
|
if ! gpg --export-ownertrust | grep --quiet $GPG_KEY_FINGERPRINT:6:
|
||||||
then echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
then echo "$GPG_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if gpg --verify "$TMP_LOCATION"/gitea.asc "$TMP_LOCATION"/gitea
|
if gpg --verify "$TMP_LOCATION"/gitea.asc "$TMP_LOCATION"/gitea
|
||||||
then rm "$TMP_LOCATION"/gitea.asc; return 0
|
then rm "$TMP_LOCATION"/gitea.asc; return 0
|
||||||
else echo "gpg verification results in a BAD signature"; exit 1
|
else echo "gpg verification results in a BAD signature"; exit 1
|
||||||
|
echo "$GPG_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# version_lower_than A B
|
## this is a helper function to compare two versions as a "lower than" operator
|
||||||
# returns whether A < B
|
function version_lt
|
||||||
function is_version_lower_than
|
|
||||||
{
|
{
|
||||||
test "$(echo "$@" | # get all version arguments
|
test "$(echo "$@" |
|
||||||
tr " " "\n" | # replace `space` with `new line`
|
tr " " "n" |
|
||||||
sed '/alpha/d; /beta/d; /rc/d' | # remove pre-release versions (version-sort interprets suffixes as patch versions)
|
sort --version-sort --reverse |
|
||||||
sort --version-sort --reverse | # latest version will be sorted to line 1
|
head --lines=1)" != "$1"
|
||||||
head --lines=1)" != "$1" # filter line 1 and compare it to A
|
|
||||||
}
|
|
||||||
|
|
||||||
function fix_stop_signal
|
|
||||||
{
|
|
||||||
if (grep --quiet HUP "$HOME"/etc/services.d/gitea.ini)
|
|
||||||
then
|
|
||||||
sed --in-place '/HUP/d' "$HOME"/etc/services.d/gitea.ini
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_update_available
|
|
||||||
{
|
|
||||||
set_local_version
|
|
||||||
set_latest_version
|
|
||||||
if is_version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function main
|
function main
|
||||||
{
|
{
|
||||||
fix_stop_signal
|
get_local_version
|
||||||
|
get_latest_version
|
||||||
|
|
||||||
if is_update_available
|
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||||
|
then
|
||||||
|
echo "Your $APP_NAME is already up to date."
|
||||||
|
echo "You are running $APP_NAME $LOCAL_VERSION"
|
||||||
|
else
|
||||||
|
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||||
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"
|
||||||
do_update_procedure
|
do_update_procedure
|
||||||
else
|
fi
|
||||||
echo "Your $APP_NAME is already up to date."
|
|
||||||
echo "You are running $APP_NAME $LOCAL_VERSION"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -6,12 +6,11 @@ LOCAL_VERSION=$(jq --raw-output .Version /var/www/virtual/"$USER"/grocy/version.
|
|||||||
TAG_NAME=$(curl -s https://api.github.com/repos/$ORG/$REPO/releases/latest | jq --raw-output .tag_name)
|
TAG_NAME=$(curl -s https://api.github.com/repos/$ORG/$REPO/releases/latest | jq --raw-output .tag_name)
|
||||||
LATEST_VERSION=${TAG_NAME:1} # It is common to use the prefix v for the version tag.
|
LATEST_VERSION=${TAG_NAME:1} # It is common to use the prefix v for the version tag.
|
||||||
|
|
||||||
## version_lower_than A B
|
## this is a helper function to compare two versions as a "lower than" operator
|
||||||
# returns whether A < B
|
function version_lt
|
||||||
function version_lower_than
|
|
||||||
{
|
{
|
||||||
test "$(echo "$@" |
|
test "$(echo "$@" |
|
||||||
tr " " "\n" |
|
tr " " "n" |
|
||||||
sort --version-sort --reverse |
|
sort --version-sort --reverse |
|
||||||
head --lines=1)" != "$1"
|
head --lines=1)" != "$1"
|
||||||
}
|
}
|
||||||
@@ -19,7 +18,7 @@ function version_lower_than
|
|||||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]; then
|
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]; then
|
||||||
echo "Your $APP is running on $LOCAL_VERSION and it is already up to date."
|
echo "Your $APP is running on $LOCAL_VERSION and it is already up to date."
|
||||||
else
|
else
|
||||||
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||||
then
|
then
|
||||||
echo "There is a new Version available of $ORG"
|
echo "There is a new Version available of $ORG"
|
||||||
echo "The latest Version is $LATEST_VERSION"
|
echo "The latest Version is $LATEST_VERSION"
|
||||||
|
|||||||
+7
-8
@@ -7,7 +7,7 @@ LATEST_VERSION=$(curl --silent https://api.github.com/repos/$ORG/$REPO/releases/
|
|||||||
jq --raw-output .tag_name)
|
jq --raw-output .tag_name)
|
||||||
|
|
||||||
function do_upgrade() {
|
function do_upgrade() {
|
||||||
supervisorctl stop hedgedoc
|
supervisorctl stop $APP_NAME
|
||||||
echo "waiting 1 minute until all processes are stopped"
|
echo "waiting 1 minute until all processes are stopped"
|
||||||
sleep 1m
|
sleep 1m
|
||||||
mv --verbose ~/hedgedoc ~/hedgedoc_"$LOCAL_VERSION"
|
mv --verbose ~/hedgedoc ~/hedgedoc_"$LOCAL_VERSION"
|
||||||
@@ -20,8 +20,8 @@ function do_upgrade() {
|
|||||||
cd ~/hedgedoc || exit
|
cd ~/hedgedoc || exit
|
||||||
bin/setup
|
bin/setup
|
||||||
echo "You may need to wait a minute until HedgeDoc is up and running."
|
echo "You may need to wait a minute until HedgeDoc is up and running."
|
||||||
supervisorctl start hedgedoc
|
supervisorctl start $APP_NAME
|
||||||
echo "If everything works fine you can delete ~/hedgedoc_$LOCAL_VERSION"
|
echo "If everything works fine you can delete ~/hedgedoc_$USED_VERSION"
|
||||||
echo "Please consider that there might be uploaded files in ~/hedgedoc_$LOCAL_VERSION/public/uploads which were not migrated to the new version if you are using the default setting."
|
echo "Please consider that there might be uploaded files in ~/hedgedoc_$LOCAL_VERSION/public/uploads which were not migrated to the new version if you are using the default setting."
|
||||||
rm --recursive ~/hedgedoc_"$LOCAL_VERSION"
|
rm --recursive ~/hedgedoc_"$LOCAL_VERSION"
|
||||||
}
|
}
|
||||||
@@ -45,12 +45,11 @@ function yes-no_question
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
## version_lower_than A B
|
## this is a helper function to compare two versions as a "lower than" operator
|
||||||
# returns whether A < B
|
function version_lt
|
||||||
function version_lower_than
|
|
||||||
{
|
{
|
||||||
test "$(echo "$@" |
|
test "$(echo "$@" |
|
||||||
tr " " "\n" |
|
tr " " "n" |
|
||||||
sort --version-sort --reverse |
|
sort --version-sort --reverse |
|
||||||
head --lines=1)" != "$1"
|
head --lines=1)" != "$1"
|
||||||
}
|
}
|
||||||
@@ -59,7 +58,7 @@ function main
|
|||||||
{
|
{
|
||||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||||
then echo "Your HedgeDoc is already up to date."
|
then echo "Your HedgeDoc is already up to date."
|
||||||
elif version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
elif version_lt "$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"
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# This script installs syntax highlighting only for shell scripts
|
|
||||||
# It is ment to be used on fresh Uberspaces
|
|
||||||
|
|
||||||
mkdir ~/.nano
|
|
||||||
cat << 'end_of_content' > ~/.nano/sh.nanorc
|
|
||||||
## Syntax highlighting for Bourne shell scripts.
|
|
||||||
## UBERSPACE EDITION (compatible with nano 2.3.1)
|
|
||||||
|
|
||||||
syntax "sh" "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
|
|
||||||
header "^#!.*/((env\s+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox\s+sh|openrc-run|runscript)\>"
|
|
||||||
header "-\*-.*shell-script.*-\*-"
|
|
||||||
magic "(POSIX|Bourne-Again) shell script.*text"
|
|
||||||
#comment "#"
|
|
||||||
|
|
||||||
#linter dash -n
|
|
||||||
|
|
||||||
# Function declarations.
|
|
||||||
color brightgreen "^[A-Za-z0-9_-]+\(\)"
|
|
||||||
|
|
||||||
# Keywords, symbols, and comparisons.
|
|
||||||
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
|
|
||||||
color green "\<(declare|eval|exec|export|let|local)\>"
|
|
||||||
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
|
|
||||||
color green "-(eq|ne|gt|lt|ge|le|ef|ot|nt)\>"
|
|
||||||
|
|
||||||
# Short and long options.
|
|
||||||
color brightmagenta "[[:blank:]]-[A-Za-z]\>" "[[:blank:]]--[A-Za-z-]+\>"
|
|
||||||
|
|
||||||
# Common commands.
|
|
||||||
color brightblue "\<(awk|cat|cd|ch(grp|mod|own)|cp|cut|echo|env|grep|head|install|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|sort|tail|tar|touch|umask|unset)\>"
|
|
||||||
#color normal "[.-]tar\>"
|
|
||||||
|
|
||||||
# Basic variable names (no braces).
|
|
||||||
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
|
|
||||||
# More complicated variable names; handles braces and replacements and arrays.
|
|
||||||
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
|
||||||
|
|
||||||
# Comments.
|
|
||||||
color cyan "(^|[[:space:]])#.*"
|
|
||||||
|
|
||||||
# Strings.
|
|
||||||
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
|
|
||||||
|
|
||||||
# Trailing whitespace.
|
|
||||||
color ,green "[[:space:]]+$"
|
|
||||||
end_of_content
|
|
||||||
|
|
||||||
cat << end_of_content >> ~/.nanorc
|
|
||||||
include "~/.nano/sh.nanorc"
|
|
||||||
end_of_content
|
|
||||||
+63
-108
@@ -1,13 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
APP_NAME=Nextcloud
|
|
||||||
|
|
||||||
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
|
read -r -p "Nextcloud admin password: " NEXTCLOUD_ADMIN_PASS
|
||||||
trusted_domain="$USER.uber.space"
|
trusted_domain="$USER.uber.space"
|
||||||
|
#setup_domains
|
||||||
setup_php
|
setup_php
|
||||||
# simply get the first password string from ~/.my.cnf
|
# simply get the first password string from ~/.my.cnf
|
||||||
MYSQL_PASSWORD_STR=$(grep --max-count=1 password= ~/.my.cnf)
|
MYSQL_PASSWORD_STR=$(grep --max-count=1 password= ~/.my.cnf)
|
||||||
@@ -21,96 +20,51 @@ function install_nextcloud
|
|||||||
if [ "$(ls --almost-all ~/html/)" ]; then echo '~/html is not empty, abort!'; exit 1; fi
|
if [ "$(ls --almost-all ~/html/)" ]; then echo '~/html is not empty, abort!'; exit 1; fi
|
||||||
cd ~/html
|
cd ~/html
|
||||||
echo "Downloading Nextcloud to ~/html/"
|
echo "Downloading Nextcloud to ~/html/"
|
||||||
release_name=$(get_version_name)
|
curl --progress-bar https://download.nextcloud.com/server/releases/"$(get_version_name)".tar.bz2 |
|
||||||
release_archive="$release_name".tar.bz2
|
tar -xjf - --strip-components=1
|
||||||
signature_file="$release_archive".asc
|
|
||||||
curl --progress-bar --remote-name https://download.nextcloud.com/server/releases/"$release_archive"
|
|
||||||
curl --silent --remote-name https://download.nextcloud.com/server/releases/"$signature_file"
|
|
||||||
curl --silent --remote-name https://nextcloud.com/nextcloud.asc
|
|
||||||
gpg --import nextcloud.asc
|
|
||||||
PGP_KEY_FINGERPRINT='28806A878AE423A28372792ED75899B9A724937A'
|
|
||||||
#gpg --keyserver pgp.mit.edu --recv-keys $PGP_KEY_FINGERPRINT
|
|
||||||
echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
|
||||||
if ! gpg --verify "$signature_file" "$release_archive"
|
|
||||||
then echo "gpg verification results in a BAD signature"; exit 1
|
|
||||||
fi
|
|
||||||
echo "Extracting archive"
|
|
||||||
tar -xjf "$release_archive" --strip-components=1
|
|
||||||
rm "$release_archive" "$signature_file" nextcloud.asc
|
|
||||||
mysql --verbose --execute="CREATE DATABASE ${USER}_nextcloud"
|
mysql --verbose --execute="CREATE DATABASE ${USER}_nextcloud"
|
||||||
echo "Installing Nextcloud"
|
echo "Installing Nextcloud"
|
||||||
install_ncc
|
php ~/html/occ maintenance:install \
|
||||||
ncc maintenance:install \
|
--admin-user "${NEXTCLOUD_ADMIN_USER}" \
|
||||||
--admin-user="${NEXTCLOUD_ADMIN_USER}" \
|
--admin-pass "${NEXTCLOUD_ADMIN_PASS}" \
|
||||||
--admin-pass="${NEXTCLOUD_ADMIN_PASS}" \
|
--database 'mysql' --database-name "${USER}_nextcloud" \
|
||||||
--database='mysql' \
|
--database-user "${USER}" \
|
||||||
--database-name="${USER}_nextcloud" \
|
--database-pass "${MYSQL_PASSWORD}" \
|
||||||
--database-user="${USER}" \
|
--data-dir "${HOME}/nextcloud_data"
|
||||||
--database-pass="${MYSQL_PASSWORD}" \
|
|
||||||
--data-dir="${HOME}/nextcloud_data"
|
|
||||||
|
|
||||||
ncc config:system:set trusted_domains 0 --value="$trusted_domain"
|
php ~/html/occ config:system:set trusted_domains 0 --value="$trusted_domain"
|
||||||
ncc config:system:set overwrite.cli.url --value="https://$trusted_domain"
|
php ~/html/occ config:system:set overwrite.cli.url --value="https://$trusted_domain"
|
||||||
|
|
||||||
echo "Setting symbolic links for more easy log file access"
|
echo "Setting symbolic links for more easy log file access"
|
||||||
ln --symbolic --verbose ~/nextcloud_data/nextcloud.log ~/logs/nextcloud.log
|
ln --symbolic --verbose ~/nextcloud_data/nextcloud.log ~/logs/nextcloud.log
|
||||||
ln --symbolic --verbose ~/nextcloud_data/updater.log ~/logs/nextcloud-updater.log
|
ln --symbolic --verbose ~/nextcloud_data/updater.log ~/logs/nextcloud-updater.log
|
||||||
|
|
||||||
ncc config:system:set mail_domain --value="uber.space"
|
php ~/html/occ config:system:set mail_domain --value="uber.space"
|
||||||
ncc config:system:set mail_from_address --value="$USER"
|
php ~/html/occ config:system:set mail_from_address --value="$USER"
|
||||||
ncc config:system:set mail_smtpmode --value="sendmail"
|
php ~/html/occ config:system:set mail_smtpmode --value="sendmail"
|
||||||
ncc config:system:set mail_sendmailmode --value="pipe"
|
php ~/html/occ config:system:set mail_sendmailmode --value="pipe"
|
||||||
|
|
||||||
ncc config:system:set htaccess.RewriteBase --value='/'
|
php ~/html/occ config:system:set htaccess.RewriteBase --value='/'
|
||||||
ncc maintenance:update:htaccess
|
php ~/html/occ maintenance:update:htaccess
|
||||||
|
|
||||||
echo "*/5 * * * * sleep $(( 1 + RANDOM % 60 )); php -f $HOME/html/cron.php > $HOME/logs/nextcloud-cron.log 2>&1" |
|
echo "*/5 * * * * php -f $HOME/html/cron.php > $HOME/logs/nextcloud-cron.log 2>&1" |
|
||||||
crontab -
|
crontab -
|
||||||
ncc background:cron
|
php ~/html/occ background:cron
|
||||||
|
|
||||||
ncc config:system:set memcache.local --value='\OC\Memcache\APCu'
|
php ~/html/occ config:system:set memcache.local --value='\OC\Memcache\APCu'
|
||||||
ncc config:system:set default_phone_region --value='DE'
|
php ~/html/occ config:system:set default_phone_region --value='DE'
|
||||||
|
|
||||||
setup_redis
|
setup_redis
|
||||||
install_notify_push
|
install_notify_push
|
||||||
install_nextcloud_updater
|
install_nextcloud_updater
|
||||||
|
install_ncc
|
||||||
|
|
||||||
/usr/sbin/restorecon -R ~/html
|
/usr/sbin/restorecon -R ~/html
|
||||||
|
|
||||||
printf "If you want to use another domain read:\n https://lab.uberspace.de/guide_nextcloud/#set-the-trusted-domain\n"
|
printf "If you want to use another domain read:\n https://lab.uberspace.de/guide_nextcloud.html#set-the-trusted-domain\n"
|
||||||
printf "You can now access your Nextcloud by directing you Browser to: \n https://%s \n" "$trusted_domain"
|
printf "You can now access your Nextcloud by directing you Browser to: \n https://%s \n" "$trusted_domain"
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstall_nextcloud
|
|
||||||
{
|
|
||||||
unset_critical_section
|
|
||||||
if ! yes_no_question "Do you want to keep the Nextcloud user files?"
|
|
||||||
then rm -r ~/nextcloud_data
|
|
||||||
fi
|
|
||||||
if test -f ~/etc/services.d/notify_push.ini
|
|
||||||
then
|
|
||||||
supervisorctl stop notify_push
|
|
||||||
rm ~/etc/services.d/notify_push.ini
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update
|
|
||||||
fi
|
|
||||||
if test -f ~/etc/services.d/redis.ini
|
|
||||||
then
|
|
||||||
supervisorctl stop redis
|
|
||||||
rm ~/etc/services.d/redis.ini
|
|
||||||
rm -r ~/.redis
|
|
||||||
supervisorctl reread
|
|
||||||
supervisorctl update
|
|
||||||
fi
|
|
||||||
rm -r ~/html/* ~/html/.htaccess ~/html/.user.ini ~/_nextcloud_completion
|
|
||||||
mysql --verbose --execute="DROP DATABASE ${USER}_nextcloud"
|
|
||||||
rm ~/bin/ncc ~/bin/nextcloud-update
|
|
||||||
unlink ~/bin/notify_push
|
|
||||||
unlink ~/logs/nextcloud.log
|
|
||||||
unlink ~/logs/nextcloud-updater.log
|
|
||||||
set_critical_section
|
|
||||||
}
|
|
||||||
|
|
||||||
function process_parameters
|
function process_parameters
|
||||||
{
|
{
|
||||||
while test $# -gt 0
|
while test $# -gt 0
|
||||||
@@ -122,13 +76,6 @@ function process_parameters
|
|||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
uninstall )
|
|
||||||
echo "This command tries to revert the $APP_NAME installation, it will delete all of its scripts, service config, ~/nextcloud_data directory with all contents and drops the database."
|
|
||||||
if yes_no_question "Do you really want to do this?"
|
|
||||||
then uninstall_nextcloud
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
* )
|
* )
|
||||||
echo "$1 can not be processed, exiting script"
|
echo "$1 can not be processed, exiting script"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -145,10 +92,26 @@ function get_version_name
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setup_domains
|
||||||
|
{
|
||||||
|
echo "You currently have configured the following domains:"
|
||||||
|
uberspace web domain list
|
||||||
|
if yes-no_question "Do you want to add another domain to the web configuration of your uberspace?"
|
||||||
|
then add_domain
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_domain
|
||||||
|
{
|
||||||
|
read -rp "Domain: " DOMAIN
|
||||||
|
uberspace web domain add "$DOMAIN"
|
||||||
|
trusted_domain=$DOMAIN
|
||||||
|
}
|
||||||
|
|
||||||
function setup_php
|
function setup_php
|
||||||
{
|
{
|
||||||
|
uberspace tools version use php 8.0
|
||||||
echo "Applying relevant PHP settings for Nextcloud"
|
echo "Applying relevant PHP settings for Nextcloud"
|
||||||
uberspace tools version use php 8.1
|
|
||||||
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
|
||||||
@@ -199,17 +162,17 @@ end_of_content
|
|||||||
supervisorctl reread
|
supervisorctl reread
|
||||||
supervisorctl update
|
supervisorctl update
|
||||||
supervisorctl status
|
supervisorctl status
|
||||||
ncc config:system:set redis host --value="${HOME}/.redis/sock"
|
php ~/html/occ config:system:set redis host --value="${HOME}/.redis/sock"
|
||||||
ncc config:system:set redis port --value=0
|
php ~/html/occ config:system:set redis port --value=0
|
||||||
ncc config:system:set redis timeout --value=1.5
|
php ~/html/occ config:system:set redis timeout --value=1.5
|
||||||
ncc config:system:set filelocking.enabled --value='true'
|
php ~/html/occ config:system:set filelocking.enabled --value='true'
|
||||||
ncc config:system:set memcache.locking --value='\OC\Memcache\Redis'
|
php ~/html/occ config:system:set memcache.locking --value='\OC\Memcache\Redis'
|
||||||
ncc config:system:set memcache.distributed --value='\OC\Memcache\Redis'
|
php ~/html/occ config:system:set memcache.distributed --value='\OC\Memcache\Redis'
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_notify_push
|
function install_notify_push
|
||||||
{
|
{
|
||||||
ncc app:install notify_push
|
php ~/html/occ app:install notify_push
|
||||||
chmod u+x --verbose ~/html/apps/notify_push/bin/x86_64/notify_push
|
chmod u+x --verbose ~/html/apps/notify_push/bin/x86_64/notify_push
|
||||||
ln --symbolic --verbose "$HOME"/html/apps/notify_push/bin/x86_64/notify_push ~/bin/notify_push
|
ln --symbolic --verbose "$HOME"/html/apps/notify_push/bin/x86_64/notify_push ~/bin/notify_push
|
||||||
touch ~/etc/services.d/notify_push.ini
|
touch ~/etc/services.d/notify_push.ini
|
||||||
@@ -228,8 +191,8 @@ end_of_content
|
|||||||
trusted_proxy=$(ip route |
|
trusted_proxy=$(ip route |
|
||||||
tail --lines 1 | ## filter last line
|
tail --lines 1 | ## filter last line
|
||||||
awk '{print $9}') ## filter the last (9.) string from that line, it is the proxy ip
|
awk '{print $9}') ## filter the last (9.) string from that line, it is the proxy ip
|
||||||
ncc config:system:set trusted_proxies 0 --value="$trusted_proxy"
|
php ~/html/occ config:system:set trusted_proxies 0 --value="$trusted_proxy"
|
||||||
ncc notify_push:setup https://"$trusted_domain"/push
|
php ~/html/occ notify_push:setup https://"$trusted_domain"/push
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_ncc
|
function install_ncc
|
||||||
@@ -237,12 +200,9 @@ function install_ncc
|
|||||||
touch ~/bin/ncc
|
touch ~/bin/ncc
|
||||||
cat << 'end_of_content' > ~/bin/ncc
|
cat << 'end_of_content' > ~/bin/ncc
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
exec php /var/www/virtual/$USER/html/occ "$@"
|
php ~/html/occ "$@"
|
||||||
end_of_content
|
end_of_content
|
||||||
chmod u+x ~/bin/ncc
|
chmod u+x ~/bin/ncc
|
||||||
chmod u+x ~/html/occ
|
|
||||||
ncc _completion --generate-hook --program=ncc > ~/_nextcloud_completion
|
|
||||||
echo "source \$HOME/_nextcloud_completion" >> ~/.bash_profile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_nextcloud_updater
|
function install_nextcloud_updater
|
||||||
@@ -251,28 +211,23 @@ function install_nextcloud_updater
|
|||||||
cat << 'end_of_content' > ~/bin/nextcloud-update
|
cat << 'end_of_content' > ~/bin/nextcloud-update
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
APP_LOCATION=~/html
|
APP_LOCATION=$HOME/html
|
||||||
|
|
||||||
function ncc
|
|
||||||
{
|
|
||||||
php $APP_LOCATION/occ "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
## 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.
|
||||||
## The Nextcloud updater creates backups only to safe base and app code data and config files
|
## The Nextcloud updater creates backups only to safe base and app code data and config files
|
||||||
## so it takes ressources you might need for your productive data.
|
## so it takes ressources you might need for your productive data.
|
||||||
## Deactivate NC-updater Backups with --no-backup
|
## Deactivate NC-updater Backups with --no-backup
|
||||||
php $APP_LOCATION/updater/updater.phar --no-backup --no-interaction
|
php "$APP_LOCATION"/updater/updater.phar --no-backup --no-interaction
|
||||||
|
|
||||||
## database optimisations
|
## database optimisations
|
||||||
ncc db:add-missing-primary-keys --no-interaction
|
php "$APP_LOCATION"/occ db:add-missing-primary-keys --no-interaction
|
||||||
ncc db:add-missing-columns --no-interaction
|
php "$APP_LOCATION"/occ db:add-missing-columns --no-interaction
|
||||||
ncc db:add-missing-indices --no-interaction
|
php "$APP_LOCATION"/occ db:add-missing-indices --no-interaction
|
||||||
ncc db:convert-filecache-bigint --no-interaction
|
php "$APP_LOCATION"/occ db:convert-filecache-bigint --no-interaction
|
||||||
|
|
||||||
ncc app:update --all
|
php "$APP_LOCATION"/occ app:update --all
|
||||||
/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
|
||||||
@@ -281,7 +236,7 @@ end_of_content
|
|||||||
chmod u+x ~/bin/nextcloud-update
|
chmod u+x ~/bin/nextcloud-update
|
||||||
}
|
}
|
||||||
|
|
||||||
function yes_no_question
|
function yes-no_question
|
||||||
{
|
{
|
||||||
local question=$1
|
local question=$1
|
||||||
while true
|
while true
|
||||||
@@ -309,16 +264,16 @@ function main
|
|||||||
|
|
||||||
if [[ -n $VERSION ]]
|
if [[ -n $VERSION ]]
|
||||||
then
|
then
|
||||||
echo "This script installs $APP_NAME $VERSION"
|
echo "This script installs Nextcloud $VERSION"
|
||||||
echo "We recommend to use the latest release."
|
echo "We recommend to use the latest release."
|
||||||
## This feature is mainly used to install older versions and then test the update script.
|
## This feature is mainly used to install older versions and then test the update script.
|
||||||
else
|
else
|
||||||
echo "This script installs the latest release of $APP_NAME"
|
echo "This script installs the latest release of Nextcloud"
|
||||||
echo "and assumes a newly created Uberspace with default settings."
|
echo "and assumes a newly created Uberspace with default settings."
|
||||||
fi
|
fi
|
||||||
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 Nextcloud?"
|
||||||
then install_nextcloud
|
then install_nextcloud
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,232 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
APP_NAME=Nextcloud
|
|
||||||
APP_LOCATION=/var/www/virtual/$USER/html
|
|
||||||
TMP_LOCATION=~/tmp
|
|
||||||
|
|
||||||
VERBOSE_OUTPUT=true
|
|
||||||
NO_BACKUP=false
|
|
||||||
NO_INTERACTION=false
|
|
||||||
|
|
||||||
ORG=nextcloud # Organisation or GitHub user
|
|
||||||
REPO=server
|
|
||||||
GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases
|
|
||||||
|
|
||||||
function ncc
|
|
||||||
{
|
|
||||||
php "$APP_LOCATION"/occ "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_verbose
|
|
||||||
{
|
|
||||||
if [[ $VERBOSE_OUTPUT == "true" ]]
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function verbose_echo
|
|
||||||
{
|
|
||||||
if is_verbose
|
|
||||||
then echo "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_current_version
|
|
||||||
{
|
|
||||||
ncc --version |
|
|
||||||
awk '{print $NF}'
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_major_version
|
|
||||||
{
|
|
||||||
local complete_version=$1
|
|
||||||
echo "$complete_version" | awk --field-separator "." '{print $1}'
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_latest_version
|
|
||||||
{
|
|
||||||
tag_name=$(curl --silent $GITHUB_API_URL > "$TMP_LOCATION"/github_api_response.json
|
|
||||||
jq . "$TMP_LOCATION"/github_api_response.json |
|
|
||||||
jq 'map(select(.tag_name | test("(v'"$MAJOR_VERSION"'.\\d+.\\d+$)")))' |
|
|
||||||
jq --raw-output '.[0].tag_name')
|
|
||||||
rm "$TMP_LOCATION"/github_api_response.json
|
|
||||||
## remove the first character 'v', for example 'v24.0.1' -> '24.0.1' using substring syntax
|
|
||||||
local version="${tag_name:1}"
|
|
||||||
echo "$version"
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_update_procedure
|
|
||||||
{
|
|
||||||
cd $TMP_LOCATION || exit 1
|
|
||||||
folder_should_not_exist "$TMP_LOCATION/nextcloud"
|
|
||||||
verbose_echo "Download latest-$MAJOR_VERSION.zip"
|
|
||||||
local release_archive="latest-$MAJOR_VERSION.zip"
|
|
||||||
local signature_file=${release_archive}.asc
|
|
||||||
curl --progress-bar --remote-name https://download.nextcloud.com/server/releases/"$release_archive"
|
|
||||||
curl --silent --remote-name https://download.nextcloud.com/server/releases/"$signature_file"
|
|
||||||
curl --silent --remote-name https://nextcloud.com/nextcloud.asc
|
|
||||||
gpg --import nextcloud.asc
|
|
||||||
if ! gpg --verify "$TMP_LOCATION/$signature_file" "$TMP_LOCATION/$release_archive"
|
|
||||||
then echo "gpg verification results in a BAD signature"; exit 1
|
|
||||||
fi
|
|
||||||
verbose_echo "unzip latest-$MAJOR_VERSION.zip"
|
|
||||||
unzip -q latest-"$MAJOR_VERSION".zip
|
|
||||||
verbose_echo "Copy config to new version"
|
|
||||||
cp "$APP_LOCATION"/config/config.php $TMP_LOCATION/nextcloud/config/
|
|
||||||
if [[ $NO_BACKUP == "true" ]]
|
|
||||||
then
|
|
||||||
verbose_echo "Delete $APP_LOCATION"
|
|
||||||
rm -r "$APP_LOCATION"
|
|
||||||
else
|
|
||||||
verbose_echo "Create application backup by moving the directory"
|
|
||||||
verbose_echo "Destination: ~/nextcloud_application_backup_$CURRENT_VERSION"
|
|
||||||
folder_should_not_exist ~/nextcloud_application_backup_"$CURRENT_VERSION"
|
|
||||||
mv "$APP_LOCATION" ~/nextcloud_application_backup_"$CURRENT_VERSION"
|
|
||||||
fi
|
|
||||||
verbose_echo "Moving new files to destination"
|
|
||||||
mv $TMP_LOCATION/nextcloud "$APP_LOCATION"
|
|
||||||
verbose_echo "Removing setup files"
|
|
||||||
rm latest-"$MAJOR_VERSION".zip
|
|
||||||
rm latest-"$MAJOR_VERSION".zip.asc
|
|
||||||
rm nextcloud.asc
|
|
||||||
## official docs: (!) this MUST be executed from within your nextcloud installation directory
|
|
||||||
cd "$APP_LOCATION" || exit 1
|
|
||||||
ncc upgrade
|
|
||||||
ncc db:add-missing-primary-keys --no-interaction
|
|
||||||
ncc db:add-missing-columns --no-interaction
|
|
||||||
ncc db:add-missing-indices --no-interaction
|
|
||||||
ncc db:convert-filecache-bigint --no-interaction
|
|
||||||
ncc app:update --all
|
|
||||||
/usr/sbin/restorecon -R "$APP_LOCATION"
|
|
||||||
if test -f ~/etc/services.d/notify_push.ini
|
|
||||||
then supervisorctl restart notify_push
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function folder_should_not_exist
|
|
||||||
{
|
|
||||||
local folder_path=$1
|
|
||||||
if test -d "$folder_path"
|
|
||||||
then
|
|
||||||
echo "The folder should not exist at this point in time. Delete or move: $folder_path"
|
|
||||||
echo "abort update procedure"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function process_parameters
|
|
||||||
{
|
|
||||||
while test $# -gt 0
|
|
||||||
do
|
|
||||||
local next_parameter=$1
|
|
||||||
case $next_parameter in
|
|
||||||
--no-backup )
|
|
||||||
NO_BACKUP=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--no-interaction )
|
|
||||||
NO_INTERACTION=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--no-verbose | --quiet )
|
|
||||||
VERBOSE_OUTPUT=false
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
echo "$next_parameter can not be processed, exiting script"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
## version_lower_than A B
|
|
||||||
# returns whether A < B
|
|
||||||
function version_lower_than
|
|
||||||
{
|
|
||||||
test "$(echo "$@" |
|
|
||||||
tr " " "\n" |
|
|
||||||
sort --version-sort --reverse |
|
|
||||||
head --lines=1)" != "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_data_used_in_nextcloud_directory
|
|
||||||
{
|
|
||||||
test -d "$APP_LOCATION"/data || return 1
|
|
||||||
# shellcheck disable=SC2012
|
|
||||||
directory_elements_counter=$(ls "$APP_LOCATION"/data | wc -l)
|
|
||||||
## Some older releases provide a data folder with a index.html file
|
|
||||||
if [[ directory_elements_counter -gt 1 ]]
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function yes_no_question
|
|
||||||
{
|
|
||||||
local question=$1
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
read -r -p "$question (y/n) " ANSWER
|
|
||||||
case $ANSWER in
|
|
||||||
[Yy]* | [Jj]* )
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
[Nn]* )
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
* ) echo "Please answer yes or no. ";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function no_interaction_mode
|
|
||||||
{
|
|
||||||
if [[ $NO_INTERACTION == "true" ]]; then return 0; else return 1; fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_critical_section { set -o pipefail -o errexit; }
|
|
||||||
function unset_critical_section { set +o pipefail +o errexit; }
|
|
||||||
|
|
||||||
function main
|
|
||||||
{
|
|
||||||
set_critical_section
|
|
||||||
|
|
||||||
process_parameters "$@"
|
|
||||||
|
|
||||||
CURRENT_VERSION=$(get_current_version)
|
|
||||||
MAJOR_VERSION=$(get_major_version "$CURRENT_VERSION")
|
|
||||||
LATEST_VERSION=$(get_latest_version)
|
|
||||||
|
|
||||||
if is_data_used_in_nextcloud_directory
|
|
||||||
then
|
|
||||||
echo "It looks like your data directory is located at the default location inside Nextcloud root"
|
|
||||||
echo "This is not supported by this update script. Please use an external location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]
|
|
||||||
then
|
|
||||||
verbose_echo "Your $APP_NAME $MAJOR_VERSION already has the latest point release."
|
|
||||||
verbose_echo "You are running $APP_NAME $CURRENT_VERSION"
|
|
||||||
if is_verbose; then ncc update:check; fi
|
|
||||||
verbose_echo "If you want to do a major update don't skip major releases."
|
|
||||||
verbose_echo "Example: 18.0.5 -> 18.0.11 -> 19.0.5 -> 20.0.2"
|
|
||||||
verbose_echo "Therefore it is recommended to use the built-in updater"
|
|
||||||
else
|
|
||||||
if version_lower_than "$CURRENT_VERSION" "$LATEST_VERSION"
|
|
||||||
then
|
|
||||||
echo "There is a new point release version available."
|
|
||||||
echo "Doing update from $CURRENT_VERSION to $LATEST_VERSION"
|
|
||||||
if no_interaction_mode || yes_no_question "Do you want to start the update procedure?"
|
|
||||||
then do_update_procedure
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset_critical_section
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
exit $?
|
|
||||||
+8
-13
@@ -1,27 +1,22 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
APP_LOCATION=~/html
|
APP_LOCATION=$HOME/html
|
||||||
|
|
||||||
function ncc
|
|
||||||
{
|
|
||||||
php $APP_LOCATION/occ "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
## 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.
|
||||||
## The Nextcloud updater creates backups only to safe base and app code data and config files
|
## The Nextcloud updater creates backups only to safe base and app code data and config files
|
||||||
## so it takes ressources you might need for your productive data.
|
## so it takes ressources you might need for your productive data.
|
||||||
## Deactivate NC-updater Backups with --no-backup
|
## Deactivate NC-updater Backups with --no-backup
|
||||||
php $APP_LOCATION/updater/updater.phar --no-backup --no-interaction
|
php "$APP_LOCATION"/updater/updater.phar --no-backup --no-interaction
|
||||||
|
|
||||||
## database optimisations
|
## database optimisations
|
||||||
ncc db:add-missing-primary-keys --no-interaction
|
php "$APP_LOCATION"/occ db:add-missing-primary-keys --no-interaction
|
||||||
ncc db:add-missing-columns --no-interaction
|
php "$APP_LOCATION"/occ db:add-missing-columns --no-interaction
|
||||||
ncc db:add-missing-indices --no-interaction
|
php "$APP_LOCATION"/occ db:add-missing-indices --no-interaction
|
||||||
ncc db:convert-filecache-bigint --no-interaction
|
php "$APP_LOCATION"/occ db:convert-filecache-bigint --no-interaction
|
||||||
|
|
||||||
ncc app:update --all
|
php "$APP_LOCATION"/occ app:update --all
|
||||||
/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
|
||||||
|
|||||||
@@ -27,12 +27,11 @@ function do_update_procedure
|
|||||||
supervisorctl status
|
supervisorctl status
|
||||||
}
|
}
|
||||||
|
|
||||||
## version_lower_than A B
|
## this is a helper function to compare two versions as a "lower than" operator
|
||||||
# returns whether A < B
|
function version_lt
|
||||||
function version_lower_than
|
|
||||||
{
|
{
|
||||||
test "$(echo "$@" |
|
test "$(echo "$@" |
|
||||||
tr " " "\n" |
|
tr " " "n" |
|
||||||
sort --version-sort --reverse |
|
sort --version-sort --reverse |
|
||||||
head --lines=1)" != "$1"
|
head --lines=1)" != "$1"
|
||||||
}
|
}
|
||||||
@@ -48,7 +47,7 @@ function main
|
|||||||
echo "Your $APP_NAME is already up to date."
|
echo "Your $APP_NAME is already up to date."
|
||||||
echo "You are running $APP_NAME $LOCAL_VERSION"
|
echo "You are running $APP_NAME $LOCAL_VERSION"
|
||||||
else
|
else
|
||||||
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||||
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"
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
mkdir --parents ~/.zsh/antigen
|
||||||
|
curl -L# git.io/antigen > ~/.zsh/antigen/antigen.zsh
|
||||||
|
|
||||||
|
cat << 'end_of_content' >> ~/.zshrc
|
||||||
|
source ~/.zsh/antigen/antigen.zsh
|
||||||
|
|
||||||
|
# Load the oh-my-zsh's library.
|
||||||
|
antigen use oh-my-zsh
|
||||||
|
|
||||||
|
# Bundles from the default repo (robbyrussell's oh-my-zsh).
|
||||||
|
antigen bundle git
|
||||||
|
antigen bundle heroku
|
||||||
|
antigen bundle pip
|
||||||
|
antigen bundle lein
|
||||||
|
antigen bundle command-not-found
|
||||||
|
|
||||||
|
# Syntax highlighting bundle.
|
||||||
|
antigen bundle zsh-users/zsh-syntax-highlighting
|
||||||
|
antigen bundle zsh-users/zsh-autosuggestions
|
||||||
|
antigen bundle zsh-users/zsh-history-substring-search
|
||||||
|
antigen bundle zsh-users/zsh-completions
|
||||||
|
|
||||||
|
# Load the theme.
|
||||||
|
antigen theme robbyrussell
|
||||||
|
|
||||||
|
# Tell Antigen that you're done.
|
||||||
|
antigen apply
|
||||||
|
end_of_content
|
||||||
|
|
||||||
|
chsh --shell /bin/zsh
|
||||||
|
exec /usr/bin/env zsh
|
||||||
Reference in new issue
Block a user