mirror of
https://github.com/EV21/uberspace-helper.git
synced 2026-10-08 04:43:18 +02:00
Compare commits
22
Commits
d360520720
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c38a5ce166
|
||
|
|
6541a32fb9
|
||
|
|
ee5d32045c
|
||
|
|
6ff8b2edef
|
||
|
|
3e1292fb7a
|
||
|
|
95096f1507
|
||
|
|
459c736e9a
|
||
|
|
f693a1517f
|
||
|
|
3d7be4de12
|
||
|
|
64ca8f3485
|
||
|
|
1f524e943f
|
||
|
|
3c00c676fd
|
||
|
|
5fdacf5b34
|
||
|
|
b1822d25ae
|
||
|
|
e74c2b0b4a
|
||
|
|
73fda71f99
|
||
|
|
d036d9c6ee
|
||
|
|
4680d6e66b
|
||
|
|
46049b148e
|
||
|
|
34e2de8e7c
|
||
|
|
2a4c107114
|
||
|
|
fbc8b0f2f6
|
No files matched your search
@@ -4,31 +4,41 @@
|
||||
- [☕ Gitea Installer](#gitea-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 following components will be set up and installed automatically:
|
||||
|
||||
* php settings
|
||||
* sendmail email settings
|
||||
* cronjob
|
||||
* prettier URLs without index.php
|
||||
* Memcaching with redis and APCu
|
||||
* Client Push (notify_push)
|
||||
* `nextcloud-update` script
|
||||
* the default phone region will be set to `DE`, you may change it after the installation to a different setting
|
||||
|
||||
- php settings
|
||||
- sendmail email settings
|
||||
- cronjob
|
||||
- prettier URLs without index.php
|
||||
- Memcaching with redis and APCu
|
||||
- Client Push (notify_push)
|
||||
- `nextcloud-update` script
|
||||
- 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:
|
||||
|
||||
```
|
||||
```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
|
||||
|
||||
<!-- markdownlint-disable-next-line MD034 -->
|
||||
https://user-images.githubusercontent.com/8345730/154812905-970c649d-4360-4846-961c-1d8363d662f2.mp4
|
||||
|
||||
<!-- unused
|
||||
[nextcloud-installer-gif-demo]: ./presentation/uberspace-nextcloud-installer.gif
|
||||
-->
|
||||
|
||||
---
|
||||
|
||||
@@ -43,6 +53,40 @@ The following steps will be done automatically:
|
||||
|
||||
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)"
|
||||
```
|
||||
|
||||
```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 ~]$
|
||||
```
|
||||
+152
-108
@@ -2,7 +2,7 @@
|
||||
|
||||
APP_NAME=Gitea
|
||||
DEFAULT_PORT=3000
|
||||
GITEA_BIN_LOCATION=$HOME/gitea/gitea
|
||||
GITEA_BINARY=$HOME/gitea/gitea
|
||||
TMP_LOCATION=$HOME/tmp
|
||||
PGP_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||
ORG=go-gitea # Organisation or GitHub user
|
||||
@@ -15,58 +15,52 @@ MYSQL_PASSWORD=${MYSQL_PASSWORD_STR:9}
|
||||
|
||||
function install_gitea
|
||||
{
|
||||
if [[ -n $USE_VERSION ]]
|
||||
then GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/tags/v$USE_VERSION
|
||||
fi
|
||||
get_download_url
|
||||
echo "Installing $APP_NAME $LATEST_VERSION"
|
||||
echo "Please set your $APP_NAME login credentials."
|
||||
read -r -p "$APP_NAME admin user: " ADMIN_USER
|
||||
read -r -p "$APP_NAME admin password: " ADMIN_PASS
|
||||
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||
ask_for_password
|
||||
echo "Download $APP_NAME $INSTALL_VERSION"
|
||||
curl --location --progress-bar --output "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||
verify_file
|
||||
mkdir --parents ~/gitea/custom/conf/
|
||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BIN_LOCATION"
|
||||
chmod u+x --verbose "$GITEA_BIN_LOCATION"
|
||||
#ln --symbolic --verbose "$GITEA_BIN_LOCATION" ~/bin/gitea
|
||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
|
||||
chmod u+x --verbose "$GITEA_BINARY"
|
||||
#ln --symbolic --verbose "$GITEA_BINARY" ~/bin/gitea
|
||||
## gitea does not recognize its real path, maybe use a wrapper for this
|
||||
install_gitea_wrapper
|
||||
ln --symbolic --verbose ~/.ssh ~/gitea/.ssh
|
||||
create_app_ini
|
||||
mysql --verbose --execute="CREATE DATABASE ${USER}_gitea"
|
||||
echo "The database initialisation may take a while ..."
|
||||
$GITEA_BIN_LOCATION migrate
|
||||
$GITEA_BINARY migrate 1>/dev/null
|
||||
create_gitea_daemon_config
|
||||
supervisorctl reread
|
||||
supervisorctl update
|
||||
supervisorctl status
|
||||
sleep 5
|
||||
supervisorctl status
|
||||
$GITEA_BIN_LOCATION admin user create \
|
||||
supervisorctl update gitea
|
||||
supervisorctl status gitea
|
||||
echo "waiting 30 seconds ..."
|
||||
sleep 30
|
||||
supervisorctl status gitea
|
||||
$GITEA_BINARY admin user create \
|
||||
--username "${ADMIN_USER}" \
|
||||
--password "${ADMIN_PASS}" \
|
||||
--email "${USER}"@uber.space \
|
||||
--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 list
|
||||
install_update_script
|
||||
echo "This is the file structure for this app"
|
||||
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
|
||||
{
|
||||
# If some files do not exist there may be some errors
|
||||
unset_critical_section
|
||||
$GITEA_BIN_LOCATION manager flush-queues
|
||||
gitea_pid=$(supervisorctl pid gitea)
|
||||
echo "Process-ID is $gitea_pid"
|
||||
fix_stop_signal
|
||||
$GITEA_BINARY manager flush-queues
|
||||
supervisorctl stop gitea
|
||||
if (ps --pid "$gitea_pid" > /dev/null)
|
||||
then echo "still running! - killing it..."; kill "$gitea_pid"
|
||||
fi
|
||||
sleep 30
|
||||
mysql --verbose --execute="DROP DATABASE ${USER}_gitea"
|
||||
rm ~/etc/services.d/gitea.ini
|
||||
@@ -74,10 +68,36 @@ function uninstall_gitea
|
||||
rm ~/bin/gitea
|
||||
rm ~/bin/gitea-update
|
||||
supervisorctl reread
|
||||
supervisorctl update
|
||||
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
|
||||
@@ -87,11 +107,14 @@ function process_parameters
|
||||
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?"
|
||||
if yes_no_question "Do you really want to do this?"
|
||||
then uninstall_gitea
|
||||
fi
|
||||
exit 0
|
||||
@@ -114,7 +137,7 @@ function install_gitea_wrapper
|
||||
export GITEA_WORK_DIR=$HOME/gitea
|
||||
|
||||
FIRST_PARAMETER="$1"
|
||||
GITEA_BIN_LOCATION=$HOME/gitea/gitea
|
||||
GITEA_BINARY=$HOME/gitea/gitea
|
||||
|
||||
case $FIRST_PARAMETER in
|
||||
start | stop | restart | status )
|
||||
@@ -133,12 +156,12 @@ case $FIRST_PARAMETER in
|
||||
## this command creates a backup zip file with db, repos, config, log, data
|
||||
## restoring the backup is more difficult
|
||||
## read: https://docs.gitea.io/en-us/backup-and-restore/#restore-command-restore
|
||||
$GITEA_BIN_LOCATION dump --tempdir $HOME/tmp
|
||||
$GITEA_BINARY dump --tempdir $HOME/tmp
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
$GITEA_BIN_LOCATION "$@"
|
||||
$GITEA_BINARY "$@"
|
||||
exit $?
|
||||
end_of_content
|
||||
chmod u+x --verbose ~/bin/gitea
|
||||
@@ -146,12 +169,13 @@ end_of_content
|
||||
|
||||
function create_app_ini
|
||||
{
|
||||
SECRET_KEY=$($GITEA_BIN_LOCATION generate secret SECRET_KEY)
|
||||
SECRET_KEY=$($GITEA_BINARY generate secret SECRET_KEY)
|
||||
cat << end_of_content > ~/gitea/custom/conf/app.ini
|
||||
[server]
|
||||
DOMAIN = $USER.uber.space
|
||||
ROOT_URL = https://%(DOMAIN)s
|
||||
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
|
||||
|
||||
[database]
|
||||
@@ -166,6 +190,9 @@ MIN_PASSWORD_LENGTH = 8
|
||||
PASSWORD_COMPLEXITY = lower
|
||||
SECRET_KEY = $SECRET_KEY
|
||||
|
||||
[session]
|
||||
COOKIE_SECURE = true
|
||||
|
||||
[service]
|
||||
DISABLE_REGISTRATION = true ; security option, only admins can create new users.
|
||||
SHOW_REGISTRATION_BUTTON = false
|
||||
@@ -175,9 +202,12 @@ DEFAULT_KEEP_EMAIL_PRIVATE = true
|
||||
NO_REPLY_ADDRESS = noreply.${USER}.uber.space
|
||||
|
||||
[mailer]
|
||||
ENABLED = true
|
||||
MAILER_TYPE = sendmail
|
||||
FROM = ${USER}@uber.space
|
||||
ENABLED = true
|
||||
PROTOCOL = sendmail
|
||||
FROM = ${USER}@uber.space
|
||||
|
||||
[other]
|
||||
SHOW_FOOTER_VERSION = false
|
||||
end_of_content
|
||||
}
|
||||
|
||||
@@ -192,16 +222,20 @@ autorestart=true
|
||||
end_of_content
|
||||
}
|
||||
|
||||
function get_download_url
|
||||
function set_install_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)
|
||||
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 |
|
||||
grep --max-count=1 "linux-amd64")
|
||||
}
|
||||
|
||||
function get_signature_file
|
||||
function download_signature_file
|
||||
{
|
||||
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
||||
grep "linux-amd64.asc")
|
||||
@@ -211,10 +245,11 @@ function get_signature_file
|
||||
|
||||
function verify_file
|
||||
{
|
||||
get_signature_file
|
||||
download_signature_file
|
||||
|
||||
## downloading public key if it does not already exist
|
||||
if ! gpg --fingerprint $PGP_KEY_FINGERPRINT
|
||||
## downloading public key if it does NOT already exist OR if it is expired
|
||||
if ! (gpg --fingerprint $PGP_KEY_FINGERPRINT) ||
|
||||
(gpg --fingerprint $PGP_KEY_FINGERPRINT | grep expired)
|
||||
then
|
||||
## currently the key download via gpg does not work on Uberspace
|
||||
#gpg --keyserver keys.openpgp.org --recv $PGP_KEY_FINGERPRINT
|
||||
@@ -237,7 +272,7 @@ function install_update_script
|
||||
#!/usr/bin/env bash
|
||||
|
||||
APP_NAME=Gitea
|
||||
GITEA_LOCATION=$HOME/gitea/gitea
|
||||
GITEA_BINARY=$HOME/gitea/gitea
|
||||
TMP_LOCATION=$HOME/tmp
|
||||
PGP_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||
|
||||
@@ -247,73 +282,72 @@ GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
|
||||
|
||||
function do_update_procedure
|
||||
{
|
||||
$GITEA_LOCATION manager flush-queues
|
||||
gitea_pid=$(supervisorctl pid gitea)
|
||||
echo "Process-ID is $gitea_pid"
|
||||
supervisorctl stop gitea
|
||||
if [[ $gitea_pid -gt 0 ]] && (ps --pid "$gitea_pid" > /dev/null)
|
||||
then echo "still running! - killing it..."; kill "$gitea_pid"
|
||||
fi
|
||||
if (lsof -nP -iTCP:3000 -sTCP:LISTEN)
|
||||
then echo "port 3000 is still in use, abbort"; exit 1
|
||||
fi
|
||||
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||
curl --location --progress-bar --output "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||
verify_file
|
||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_LOCATION"
|
||||
chmod u+x --verbose "$GITEA_LOCATION"
|
||||
$GITEA_BINARY manager flush-queues
|
||||
supervisorctl stop gitea
|
||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
|
||||
chmod u+x --verbose "$GITEA_BINARY"
|
||||
echo "$APP_NAME service takes 30 seconds to start"
|
||||
supervisorctl start gitea
|
||||
supervisorctl status gitea
|
||||
}
|
||||
|
||||
function get_local_version
|
||||
function set_local_version
|
||||
{
|
||||
LOCAL_VERSION=$($GITEA_LOCATION --version |
|
||||
LOCAL_VERSION=$($GITEA_BINARY --version |
|
||||
awk '{print $3}')
|
||||
}
|
||||
|
||||
function get_latest_version
|
||||
function set_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)
|
||||
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")
|
||||
}
|
||||
|
||||
function get_signature_file
|
||||
function download_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")
|
||||
rm $TMP_LOCATION/github_api_response.json
|
||||
wget --quiet --progress=bar:force --output-document $TMP_LOCATION/gitea.asc "$SIGNATURE_FILE_URL"
|
||||
rm "$TMP_LOCATION"/github_api_response.json
|
||||
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea.asc "$SIGNATURE_FILE_URL"
|
||||
}
|
||||
|
||||
function verify_file
|
||||
{
|
||||
get_signature_file
|
||||
download_signature_file
|
||||
|
||||
## downloading public key if it does not already exist
|
||||
if ! gpg --fingerprint $PGP_KEY_FINGERPRINT
|
||||
## downloading public key if it does NOT already exist OR if it is expired
|
||||
if ! gpg --fingerprint $PGP_KEY_FINGERPRINT ||
|
||||
(gpg --fingerprint $PGP_KEY_FINGERPRINT | grep expired)
|
||||
then
|
||||
## currently the key download via gpg does not work on Uberspace
|
||||
#gpg --keyserver keys.openpgp.org --recv $PGP_KEY_FINGERPRINT
|
||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$PGP_KEY_FINGERPRINT | gpg --import
|
||||
echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||
fi
|
||||
|
||||
if gpg --verify $TMP_LOCATION/gitea.asc $TMP_LOCATION/gitea
|
||||
then rm $TMP_LOCATION/gitea.asc; return 0
|
||||
if ! gpg --export-ownertrust | grep --quiet $PGP_KEY_FINGERPRINT:6:
|
||||
then echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
## version_lower_than A B returns whether A < B
|
||||
function version_lower_than
|
||||
# is_version_lower_than A B
|
||||
# returns whether A < B
|
||||
function is_version_lower_than
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
test "$(echo "$@" | # get all version arguments
|
||||
tr " " "\n" | # replace `space` with `new line`
|
||||
sed '/alpha/d; /beta/d; /rc/d' | # remove pre-release versions (version-sort interprets suffixes as patch versions)
|
||||
sort --version-sort --reverse | # latest version will be sorted to line 1
|
||||
head --lines=1)" != "$1" # filter line 1 and compare it to A
|
||||
}
|
||||
|
||||
function fix_stop_signal
|
||||
@@ -326,27 +360,32 @@ function fix_stop_signal
|
||||
fi
|
||||
}
|
||||
|
||||
function main
|
||||
function is_update_available
|
||||
{
|
||||
fix_stop_signal
|
||||
get_local_version
|
||||
get_latest_version
|
||||
|
||||
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_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new version available."
|
||||
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
|
||||
do_update_procedure
|
||||
fi
|
||||
set_local_version
|
||||
set_latest_version
|
||||
if is_version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then return 0
|
||||
else return 1
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
function main
|
||||
{
|
||||
fix_stop_signal
|
||||
|
||||
if is_update_available
|
||||
then
|
||||
echo "There is a new version available."
|
||||
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
|
||||
do_update_procedure
|
||||
else
|
||||
echo "Your $APP_NAME is already up to date."
|
||||
echo "You are running $APP_NAME $LOCAL_VERSION"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
exit $?
|
||||
end_of_content
|
||||
chmod u+x --verbose ~/bin/gitea-update
|
||||
@@ -354,26 +393,26 @@ end_of_content
|
||||
|
||||
function echo_tree
|
||||
{
|
||||
cat << 'end_of_content'
|
||||
.
|
||||
cat << end_of_content
|
||||
/home/$USER
|
||||
├── bin
|
||||
│ ├── [-rwxrw-r--] gitea
|
||||
│ └── [-rwxrw-r--] gitea-update
|
||||
│ ├── [-rwxrw-r--] gitea (wrapper script)
|
||||
│ └── [-rwxrw-r--] gitea-update
|
||||
├── etc
|
||||
│ ├── services.d
|
||||
│ │ └── gitea.ini
|
||||
│ └── ...
|
||||
│ ├── services.d
|
||||
│ │ └── gitea.ini
|
||||
│ └── ...
|
||||
├── gitea
|
||||
│ ├── custom
|
||||
│ │ └── conf
|
||||
│ │ └── app.ini
|
||||
│ ├── data
|
||||
│ └── [-rwxrw-r--] gitea
|
||||
│ ├── custom
|
||||
│ │ └── conf
|
||||
│ │ └── app.ini (configuration file)
|
||||
│ ├── data
|
||||
│ └── [-rwxrw-r--] gitea (binary file)
|
||||
└── ...
|
||||
end_of_content
|
||||
}
|
||||
|
||||
function yes-no_question
|
||||
function yes_no_question
|
||||
{
|
||||
local question=$1
|
||||
while true
|
||||
@@ -399,15 +438,20 @@ function main
|
||||
set_critical_section
|
||||
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 "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!"
|
||||
|
||||
if (lsof -nP -iTCP:3000 -sTCP:LISTEN)
|
||||
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?"
|
||||
if yes_no_question "Do you want to execute this installer for $APP_NAME $INSTALL_VERSION?"
|
||||
then install_gitea
|
||||
fi
|
||||
|
||||
|
||||
+43
-42
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
APP_NAME=Gitea
|
||||
GITEA_LOCATION=$HOME/gitea/gitea
|
||||
GITEA_BINARY=$HOME/gitea/gitea
|
||||
TMP_LOCATION=$HOME/tmp
|
||||
GPG_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||
PGP_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||
|
||||
ORG=go-gitea # Organisation or GitHub user
|
||||
REPO=gitea
|
||||
@@ -11,31 +11,24 @@ GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
|
||||
|
||||
function do_update_procedure
|
||||
{
|
||||
$GITEA_LOCATION manager flush-queues
|
||||
gitea_pid=$(supervisorctl pid gitea)
|
||||
echo "Process-ID is $gitea_pid"
|
||||
supervisorctl stop gitea
|
||||
if [[ $gitea_pid -gt 0 ]] && (ps --pid "$gitea_pid" > /dev/null)
|
||||
then echo "still running! - killing it..."; kill "$gitea_pid"
|
||||
fi
|
||||
if (lsof -nP -iTCP:3000 -sTCP:LISTEN)
|
||||
then echo "port 3000 is still in use, abbort"; exit 1
|
||||
fi
|
||||
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||
curl --location --progress-bar --output "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||
verify_file
|
||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_LOCATION"
|
||||
chmod u+x --verbose "$GITEA_LOCATION"
|
||||
$GITEA_BINARY manager flush-queues
|
||||
supervisorctl stop gitea
|
||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_BINARY"
|
||||
chmod u+x --verbose "$GITEA_BINARY"
|
||||
echo "$APP_NAME service takes 30 seconds to start"
|
||||
supervisorctl start gitea
|
||||
supervisorctl status gitea
|
||||
}
|
||||
|
||||
function get_local_version
|
||||
function set_local_version
|
||||
{
|
||||
LOCAL_VERSION=$($GITEA_LOCATION --version |
|
||||
LOCAL_VERSION=$($GITEA_BINARY --version |
|
||||
awk '{print $3}')
|
||||
}
|
||||
|
||||
function get_latest_version
|
||||
function set_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)
|
||||
@@ -44,7 +37,7 @@ function get_latest_version
|
||||
grep --max-count=1 "linux-amd64")
|
||||
}
|
||||
|
||||
function get_signature_file
|
||||
function download_signature_file
|
||||
{
|
||||
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
||||
grep "linux-amd64.asc")
|
||||
@@ -54,18 +47,19 @@ function get_signature_file
|
||||
|
||||
function verify_file
|
||||
{
|
||||
get_signature_file
|
||||
download_signature_file
|
||||
|
||||
## downloading public key if it does not already exist
|
||||
if ! gpg --fingerprint $GPG_KEY_FINGERPRINT
|
||||
## downloading public key if it does NOT already exist OR if it is expired
|
||||
if ! gpg --fingerprint $PGP_KEY_FINGERPRINT ||
|
||||
(gpg --fingerprint $PGP_KEY_FINGERPRINT | grep expired)
|
||||
then
|
||||
## currently the key download via gpg does not work on Uberspace
|
||||
#gpg --keyserver keys.openpgp.org --recv $GPG_KEY_FINGERPRINT
|
||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$GPG_KEY_FINGERPRINT | gpg --import
|
||||
#gpg --keyserver keys.openpgp.org --recv $PGP_KEY_FINGERPRINT
|
||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$PGP_KEY_FINGERPRINT | gpg --import
|
||||
fi
|
||||
|
||||
if ! gpg --export-ownertrust | grep --quiet $GPG_KEY_FINGERPRINT:6:
|
||||
then echo "$GPG_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||
if ! gpg --export-ownertrust | grep --quiet $PGP_KEY_FINGERPRINT:6:
|
||||
then echo "$PGP_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||
fi
|
||||
|
||||
if gpg --verify "$TMP_LOCATION"/gitea.asc "$TMP_LOCATION"/gitea
|
||||
@@ -74,13 +68,15 @@ function verify_file
|
||||
fi
|
||||
}
|
||||
|
||||
## version_lower_than A B returns whether A < B
|
||||
function version_lower_than
|
||||
# is_version_lower_than A B
|
||||
# returns whether A < B
|
||||
function is_version_lower_than
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
test "$(echo "$@" | # get all version arguments
|
||||
tr " " "\n" | # replace `space` with `new line`
|
||||
sed '/alpha/d; /beta/d; /rc/d' | # remove pre-release versions (version-sort interprets suffixes as patch versions)
|
||||
sort --version-sort --reverse | # latest version will be sorted to line 1
|
||||
head --lines=1)" != "$1" # filter line 1 and compare it to A
|
||||
}
|
||||
|
||||
function fix_stop_signal
|
||||
@@ -93,23 +89,28 @@ function fix_stop_signal
|
||||
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
|
||||
{
|
||||
fix_stop_signal
|
||||
get_local_version
|
||||
get_latest_version
|
||||
|
||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||
if is_update_available
|
||||
then
|
||||
echo "There is a new version available."
|
||||
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
|
||||
do_update_procedure
|
||||
else
|
||||
echo "Your $APP_NAME is already up to date."
|
||||
echo "You are running $APP_NAME $LOCAL_VERSION"
|
||||
else
|
||||
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new version available."
|
||||
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
|
||||
do_update_procedure
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -6,11 +6,12 @@ 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)
|
||||
LATEST_VERSION=${TAG_NAME:1} # It is common to use the prefix v for the version tag.
|
||||
|
||||
## this is a helper function to compare two versions as a "lower than" operator
|
||||
function version_lt
|
||||
## version_lower_than A B
|
||||
# returns whether A < B
|
||||
function version_lower_than
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
tr " " "\n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
}
|
||||
@@ -18,7 +19,7 @@ function version_lt
|
||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]; then
|
||||
echo "Your $APP is running on $LOCAL_VERSION and it is already up to date."
|
||||
else
|
||||
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new Version available of $ORG"
|
||||
echo "The latest Version is $LATEST_VERSION"
|
||||
|
||||
+18
-9
@@ -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 |
|
||||
jq --raw-output .tag_name)
|
||||
|
||||
function do_upgrade() {
|
||||
function do_upgrade
|
||||
{
|
||||
supervisorctl stop hedgedoc
|
||||
echo "waiting 1 minute until all processes are stopped"
|
||||
sleep 1m
|
||||
@@ -26,7 +27,7 @@ function do_upgrade() {
|
||||
rm --recursive ~/hedgedoc_"$LOCAL_VERSION"
|
||||
}
|
||||
|
||||
function yes-no_question
|
||||
function yes_no_question
|
||||
{
|
||||
local question=$1
|
||||
while true
|
||||
@@ -45,20 +46,27 @@ function yes-no_question
|
||||
done
|
||||
}
|
||||
|
||||
## this is a helper function to compare two versions as a "lower than" operator
|
||||
function version_lt
|
||||
# is_version_lower_than A B
|
||||
# returns whether A < B
|
||||
function is_version_lower_than
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
tr " " "\n" |
|
||||
sort --version-sort --reverse |
|
||||
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
|
||||
{
|
||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||
then echo "Your HedgeDoc is already up to date."
|
||||
elif version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
if is_update_available
|
||||
then
|
||||
echo "There is a new Version available of $APP_NAME"
|
||||
echo "The latest Version is $LATEST_VERSION"
|
||||
@@ -67,9 +75,10 @@ function main
|
||||
echo "Please read the release notes."
|
||||
echo "Also check if the upgrade instructions have changed."
|
||||
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
|
||||
fi
|
||||
else echo "Your HedgeDoc is already up to date."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/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
|
||||
+66
-34
@@ -1,14 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
APP_NAME=Nextcloud
|
||||
PHP_VERSION=8.2
|
||||
|
||||
PGP_KEY_FINGERPRINT='28806A878AE423A28372792ED75899B9A724937A'
|
||||
|
||||
function install_nextcloud
|
||||
{
|
||||
echo "Please set your Nextcloud login credentials."
|
||||
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"
|
||||
#setup_domains
|
||||
setup_php
|
||||
# simply get the first password string from ~/.my.cnf
|
||||
MYSQL_PASSWORD_STR=$(grep --max-count=1 password= ~/.my.cnf)
|
||||
@@ -29,7 +31,6 @@ function install_nextcloud
|
||||
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"
|
||||
@@ -42,12 +43,13 @@ function install_nextcloud
|
||||
echo "Installing Nextcloud"
|
||||
install_ncc
|
||||
ncc maintenance:install \
|
||||
--admin-user "${NEXTCLOUD_ADMIN_USER}" \
|
||||
--admin-pass "${NEXTCLOUD_ADMIN_PASS}" \
|
||||
--database 'mysql' --database-name "${USER}_nextcloud" \
|
||||
--database-user "${USER}" \
|
||||
--database-pass "${MYSQL_PASSWORD}" \
|
||||
--data-dir "${HOME}/nextcloud_data"
|
||||
--admin-user="${NEXTCLOUD_ADMIN_USER}" \
|
||||
--admin-pass="${NEXTCLOUD_ADMIN_PASS}" \
|
||||
--database='mysql' \
|
||||
--database-name="${USER}_nextcloud" \
|
||||
--database-user="${USER}" \
|
||||
--database-pass="${MYSQL_PASSWORD}" \
|
||||
--data-dir="${HOME}/nextcloud_data"
|
||||
|
||||
ncc config:system:set trusted_domains 0 --value="$trusted_domain"
|
||||
ncc config:system:set overwrite.cli.url --value="https://$trusted_domain"
|
||||
@@ -84,11 +86,12 @@ function install_nextcloud
|
||||
function uninstall_nextcloud
|
||||
{
|
||||
unset_critical_section
|
||||
if ! yes-no_question "Do you want to keep the Nextcloud user files?"
|
||||
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
|
||||
uberspace web backend del /push
|
||||
supervisorctl stop notify_push
|
||||
rm ~/etc/services.d/notify_push.ini
|
||||
supervisorctl reread
|
||||
@@ -102,15 +105,30 @@ function uninstall_nextcloud
|
||||
supervisorctl reread
|
||||
supervisorctl update
|
||||
fi
|
||||
rm -r ~/html/* ~/html/.htaccess ~/html/.user.ini
|
||||
rm -r ~/html/* ~/html/.htaccess ~/html/.user.ini ~/_nextcloud_completion
|
||||
mysql --verbose --execute="DROP DATABASE ${USER}_nextcloud"
|
||||
rm ~/bin/ncc ~/bin/nextcloud-update
|
||||
sed --in-place '/_nextcloud_completion/d' ~/.bash_profile
|
||||
unlink ~/bin/notify_push
|
||||
unlink ~/logs/nextcloud.log
|
||||
unlink ~/logs/nextcloud-updater.log
|
||||
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
|
||||
{
|
||||
while test $# -gt 0
|
||||
@@ -124,7 +142,7 @@ function process_parameters
|
||||
;;
|
||||
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?"
|
||||
if yes_no_question "Do you really want to do this?"
|
||||
then uninstall_nextcloud
|
||||
fi
|
||||
exit 0
|
||||
@@ -145,26 +163,10 @@ function get_version_name
|
||||
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
|
||||
{
|
||||
uberspace tools version use php 8.0
|
||||
echo "Applying relevant PHP settings for Nextcloud"
|
||||
uberspace tools version use php $PHP_VERSION
|
||||
touch ~/etc/php.d/opcache.ini
|
||||
cat << end_of_content > ~/etc/php.d/opcache.ini
|
||||
opcache.enable=1
|
||||
@@ -239,7 +241,10 @@ end_of_content
|
||||
supervisorctl update
|
||||
supervisorctl status
|
||||
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
|
||||
trusted_proxy=$(ip route |
|
||||
tail --lines 1 | ## filter last line
|
||||
@@ -253,9 +258,12 @@ function install_ncc
|
||||
touch ~/bin/ncc
|
||||
cat << 'end_of_content' > ~/bin/ncc
|
||||
#!/usr/bin/env bash
|
||||
php ~/html/occ "$@"
|
||||
exec php /var/www/virtual/$USER/html/occ "$@"
|
||||
end_of_content
|
||||
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
|
||||
@@ -285,6 +293,8 @@ ncc db:add-missing-indices --no-interaction
|
||||
ncc db:convert-filecache-bigint --no-interaction
|
||||
|
||||
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
|
||||
|
||||
if test -f ~/etc/services.d/notify_push.ini
|
||||
@@ -294,7 +304,7 @@ end_of_content
|
||||
chmod u+x ~/bin/nextcloud-update
|
||||
}
|
||||
|
||||
function yes-no_question
|
||||
function yes_no_question
|
||||
{
|
||||
local question=$1
|
||||
while true
|
||||
@@ -312,6 +322,27 @@ function yes-no_question
|
||||
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 unset_critical_section { set +o pipefail +o errexit; }
|
||||
|
||||
@@ -329,9 +360,10 @@ function main
|
||||
echo "This script installs the latest release of $APP_NAME"
|
||||
echo "and assumes a newly created Uberspace with default settings."
|
||||
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!"
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ function do_update_procedure
|
||||
ncc db:add-missing-indices --no-interaction
|
||||
ncc db:convert-filecache-bigint --no-interaction
|
||||
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"
|
||||
if test -f ~/etc/services.d/notify_push.ini
|
||||
then supervisorctl restart notify_push
|
||||
@@ -146,7 +148,7 @@ function process_parameters
|
||||
function version_lower_than
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
tr " " "\n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
}
|
||||
@@ -163,7 +165,7 @@ function is_data_used_in_nextcloud_directory
|
||||
fi
|
||||
}
|
||||
|
||||
function yes-no_question
|
||||
function yes_no_question
|
||||
{
|
||||
local question=$1
|
||||
while true
|
||||
@@ -219,7 +221,7 @@ function main
|
||||
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?"
|
||||
if no_interaction_mode || yes_no_question "Do you want to start the update procedure?"
|
||||
then do_update_procedure
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -21,6 +21,8 @@ ncc db:add-missing-indices --no-interaction
|
||||
ncc db:convert-filecache-bigint --no-interaction
|
||||
|
||||
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
|
||||
|
||||
if test -f ~/etc/services.d/notify_push.ini
|
||||
|
||||
@@ -27,11 +27,12 @@ function do_update_procedure
|
||||
supervisorctl status
|
||||
}
|
||||
|
||||
## this is a helper function to compare two versions as a "lower than" operator
|
||||
function version_lt
|
||||
## version_lower_than A B
|
||||
# returns whether A < B
|
||||
function version_lower_than
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
tr " " "\n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
}
|
||||
@@ -47,7 +48,7 @@ function main
|
||||
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"
|
||||
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new version available."
|
||||
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
|
||||
|
||||
Reference in new issue
Block a user