parent
61626a06a5
commit
ff896b2f76
110
gitea_install.sh
110
gitea_install.sh
|
@ -4,24 +4,120 @@ set -Eeuo pipefail # See: https://vaneyckt.io/posts/safer_bash_scripts_with_set_
|
|||
<< '.SYNOPSIS'
|
||||
Einfaches Script basierend auf der Anleitung von https://lab.uberspace.de/guide_gitea/
|
||||
- Es wird damit die komplette Einrichtung von Gitea automatisiert
|
||||
- Dieses Script geht davon aus das es in einer Subdomain und nicht im Verzeichnis HTML installiert wird
|
||||
- Dieses Script geht davon aus das es in einer DOMAIN und nicht im Verzeichnis HTML installiert wird
|
||||
- Nicht vergessen alle Variablen welche ein !!!CHANGE ME!!! beinhalten zu ändern;)
|
||||
|
||||
.SYNOPSIS
|
||||
|
||||
# Kann wahrscheinlich im Script entfernt werden aber ich Nulle gerne vorher Variablen bevor ich diese zum Einsatz bringe.
|
||||
SECRET_KEY = $($NULL)
|
||||
SQL_PW = $($NULL)
|
||||
|
||||
SQL_PW = $(my_print_defaults client | tail -1 | awk -F'=' '{print $2}')
|
||||
USER = $(whoami)
|
||||
|
||||
SUBDOMAIN = !!!CHANGE ME!!!
|
||||
ADMIN_USERNAME = !!!CHANGE ME!!!
|
||||
ADMIN_PASSWORD = !!!CHANGE ME!!!
|
||||
DOMAIN = !!!CHANGE ME!!! # Link welcher verwendet wird um auf die Seite zuzugreifen.
|
||||
ADMIN_USERNAME = !!!CHANGE ME!!! # Name des Adminaccounts
|
||||
ADMIN_PASSWORD = !!!CHANGE ME!!! # Adminpasswort welches später verwendet werden soll
|
||||
ADMIN_MAIL = !!!CHANGE ME!!! # Mail Adresse für den Adminaccount
|
||||
|
||||
# Überprüft die Repo nach der aktullen Version und speichert die Versionsnummer in eine Variable
|
||||
VERSION = curl -s -L https://api.github.com/repos/go-gitea/gitea/releases | grep 'tag_name":' | head -n 1 | awk -F 'v' '{print substr($2, 1, length($2)-2)}'
|
||||
|
||||
uberspace web domain add ${SUBDOMAIN}
|
||||
uberspace web backend set ${SUBDOMAIN} --http --port 3000
|
||||
uberspace web domain add ${DOMAIN}
|
||||
uberspace web backend set ${DOMAIN} --http --port 3000
|
||||
|
||||
mysql --execute "CREATE DATABASE ${USER}_gitea"
|
||||
|
||||
cd /var/www/virtual/${USER}/${SUBDOMAIN}/
|
||||
cd /var/www/virtual/${USER}/${DOMAIN}/
|
||||
|
||||
wget -O /var/www/virtual/${USER}/${DOMAIN}/gitea https://github.com/go-gitea/gitea/releases/download/v${VERSION}/gitea-${VERSION}-linux-amd64
|
||||
|
||||
chmod u+x /var/www/virtual/${USER}/${DOMAIN}/gitea
|
||||
|
||||
wget --output-document /var/www/virtual/${USER}/${DOMAIN}/gitea.asc https://github.com/go-gitea/gitea/releases/download/v${VERSION}/gitea-${VERSION}-linux-amd64.asc
|
||||
|
||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/7C9E68152594688862D62AF62D9AE806EC1592E2 | gpg --import
|
||||
|
||||
gpg --verify /var/www/virtual/${USER}/${DOMAIN}/gitea.asc /var/www/virtual/${USER}/${DOMAIN}/gitea
|
||||
|
||||
chmod u+x ~/gitea/gitea
|
||||
SECRET_KEY=$(./gitea generate secret SECRET_KEY)
|
||||
|
||||
echo $SECRET_KEY
|
||||
|
||||
mkdir --parents /var/www/virtual/${USER}/${DOMAIN}/custom/conf/
|
||||
#
|
||||
# Etwas Backgroud zu cat><<EOL
|
||||
# https://de.wikipedia.org/wiki/Heredoc
|
||||
#
|
||||
|
||||
|
||||
cat >/var/www/virtual/${USER}/${DOMAIN}/custom/conf/app.ini <<EOL
|
||||
[database]
|
||||
DB_TYPE = mysql
|
||||
NAME = ${USER}_gitea
|
||||
USER = ${USER}
|
||||
PASSWD = ${SQL_PW}
|
||||
|
||||
[mailer]
|
||||
ENABLED = true
|
||||
PROTOCOL = sendmail
|
||||
FROM = no-reply@${DOMAIN}
|
||||
|
||||
# OPTIONAL!
|
||||
[openid]
|
||||
ENABLE_OPENID_SIGNUP = false
|
||||
ENABLE_OPENID_SIGNIN = false
|
||||
|
||||
# OPTIONAL!
|
||||
[repository]
|
||||
DISABLE_HTTP_GIT = true
|
||||
PREFERRED_LICENSES = AGPL-3.0-or-later
|
||||
|
||||
[security]
|
||||
COOKIE_REMEMBER_NAME = gitea_${DOMAIN}
|
||||
INSTALL_LOCK = true
|
||||
MIN_PASSWORD_LENGTH = 8
|
||||
PASSWORD_CHECK_PWN = true
|
||||
PASSWORD_COMPLEXITY = lower
|
||||
SECRET_KEY = ${SECRET_KEY}
|
||||
|
||||
[server]
|
||||
DOMAIN = ${DOMAIN}
|
||||
ROOT_URL = https://%(DOMAIN)s
|
||||
OFFLINE_MODE = true
|
||||
LFS_START_SERVER = true
|
||||
|
||||
[service]
|
||||
DISABLE_REGISTRATION = true
|
||||
SHOW_REGISTRATION_BUTTON = false
|
||||
REGISTER_EMAIL_CONFIRM = true
|
||||
DEFAULT_ORG_VISIBILITY = private
|
||||
DEFAULT_KEEP_EMAIL_PRIVATE = true
|
||||
NO_REPLY_ADDRESS = noreply.${USER}.uber.space
|
||||
|
||||
[other]
|
||||
SHOW_FOOTER_VERSION = false
|
||||
|
||||
EOL
|
||||
|
||||
SECRET_KEY=$($NULL) # Auch hier: Wird wahrscheinlich in einem Script nicht benötigt ;)
|
||||
SQL_PW=$($NULL) # Auch hier: Wird wahrscheinlich in einem Script nicht benötigt ;)
|
||||
|
||||
./gitea migrate
|
||||
./gitea admin user create --username ${ADMIN_USERNAME} --password ${ADMIN_PASSWORD} --email ${ADMIN_MAIL} --admin
|
||||
|
||||
ADMIN_PASSWORD=$($NULL) # Auch hier: Wird wahrscheinlich in einem Script nicht benötigt ;)
|
||||
|
||||
cat >~/etc/services.d/gitea.ini<<EOL
|
||||
[program:gitea]
|
||||
directory=/var/www/virtual/${USER}/${DOMAIN}
|
||||
command=/var/www/virtual/${USER}/${DOMAIN}/gitea web
|
||||
startsecs=30
|
||||
autorestart=yes
|
||||
EOL
|
||||
|
||||
supervisorctl reread
|
||||
supervisorctl update
|
||||
supervisorctl status
|
Loading…
Reference in New Issue