mirror of
https://gh.llkk.cc/https://github.com/WeblateOrg/scripts.git
synced 2025-10-03 15:01:00 +08:00
Add remote installation support
This commit is contained in:
parent
c359230e92
commit
dde303b703
3 changed files with 93 additions and 8 deletions
26
bootstrap
26
bootstrap
|
@ -4,18 +4,30 @@ echo "Weblate domain:"
|
|||
read domain
|
||||
echo "Weblate title:"
|
||||
read title
|
||||
echo "Sentry DSN:"
|
||||
read sentry
|
||||
echo "Sentry Token:"
|
||||
read sentry_token
|
||||
if [ -f ~/.config/weblate-bootstrap/sentry_dsn ] ; then
|
||||
sentry=$(cat ~/.config/weblate-bootstrap/sentry_dsn)
|
||||
else
|
||||
echo "Sentry DSN:"
|
||||
read sentry
|
||||
fi
|
||||
if [ -f ~/.config/weblate-bootstrap/sentry_token ] ; then
|
||||
sentry_token=$(cat ~/.config/weblate-bootstrap/sentry_token)
|
||||
else
|
||||
echo "Sentry Token:"
|
||||
read sentry_token
|
||||
fi
|
||||
echo "Matomo site id:"
|
||||
read matomo
|
||||
echo "Matomo token:"
|
||||
read matomo_token
|
||||
if [ -f ~/.config/weblate-bootstrap/matomo_token ] ; then
|
||||
matomo_token=$(cat ~/.config/weblate-bootstrap/matomo_token)
|
||||
else
|
||||
echo "Matomo token:"
|
||||
read matomo_token
|
||||
fi
|
||||
|
||||
smtp_pass=$(openssl rand -hex 32)
|
||||
|
||||
cat > /etc/weblate-bootstrap <<EOT
|
||||
cat > ${1:-/etc/weblate-bootstrap} <<EOT
|
||||
WEBLATE_DOMAIN="$domain"
|
||||
WEBLATE_TITLE="$title"
|
||||
WEBLATE_SECRET=$(openssl rand -hex 32)
|
||||
|
|
66
install-remote
Executable file
66
install-remote
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/sh
|
||||
# Installation wrapper to create Weblate instance on Hetzner cloud
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" -o "x$1" = "x--help" ] ; then
|
||||
echo "Usage: install-remote HOSTNAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set path to include script directory
|
||||
export PATH="$(dirname "$(readlink -f "$0")"):$PATH"
|
||||
|
||||
BOOTSTRAP=$(mktemp --tmpdir weblate-bootstrap.XXXXXXXXXX)
|
||||
TMPFILE=$(mktemp --tmpdir weblate-log.XXXXXXXXXX)
|
||||
|
||||
# Gather basic configuration
|
||||
bootstrap $BOOTSTRAP
|
||||
echo >> $BOOTSTRAP <<EOT
|
||||
WEBLATE_PASSWORD="$(apg -a 0 -M sncl -n 1 -x 10 -m 20)"
|
||||
EOT
|
||||
. $BOOTSTRAP
|
||||
|
||||
# Create server
|
||||
hcloud server create \
|
||||
--image debian-10 \
|
||||
--location nbg1 \
|
||||
--name $1 \
|
||||
--network 19990 \
|
||||
--ssh-key 1056953 \
|
||||
--type cx21-ceph | tee $TMPFILE
|
||||
|
||||
IPADDRESS=$(sed -n 's/IPv4: \(.*\)/\1/p' $TMPFILE)
|
||||
|
||||
echo "Created server with address $IPADDRESS, please ensure $WEBLATE_DOMAIN points to that"
|
||||
read x
|
||||
|
||||
s() {
|
||||
ssh root@$IPADDRESS "$@"
|
||||
}
|
||||
|
||||
# Install the system
|
||||
scp $BOOTSTRAP root@$IPADDRESS:/etc/weblate-bootstrap
|
||||
s apt update
|
||||
s apt install -y git
|
||||
s git clone https://github.com/WeblateOrg/scripts.git
|
||||
s ./scripts/configure-system
|
||||
s ./scripts/install-exim
|
||||
s ./scripts/install-posgtresql
|
||||
s ./scripts/install-weblate
|
||||
s ./scripts/install-munin
|
||||
|
||||
# Configure mail sending
|
||||
echo "$WEBLATE_DOMAIN:$(openssl passwd -6 -salt $(openssl rand -hex 6) "$EXIM_PASS"):666:0:99999:7::" | ssh root@mail tee --append /etc/exim4/passwd
|
||||
ssh root@mail ln -s /etc/exim4/virtual/weblate.cloud /etc/exim4/virtual/$WEBLATE_DOMAIN
|
||||
|
||||
# Print list of things to do
|
||||
echo "TODO:"
|
||||
echo " * Store password: $WEBLATE_PASSWORD"
|
||||
echo " * Add $IPADDRESS to SSH configuration"
|
||||
echo " * Add host to munin: $(s ip -f inet address show ens10 | sed -En -e 's/.*inet ([0-9.]+).*/\1/p')"
|
||||
echo " * Link with purchased service"
|
||||
echo " * Activate and verify backups"
|
||||
echo " * Verify SMTP is working"
|
||||
|
||||
rm -f $BOOTSTRAP $TMPFILE
|
|
@ -103,12 +103,19 @@ DEFAULT_COMMITER_EMAIL = 'hosted@weblate.org'
|
|||
DEFAULT_COMMITER_NAME = 'Hosted Weblate'
|
||||
LOGIN_REQUIRED_URLS = (r'/(.*)$', )
|
||||
STATUS_URL = "https://status.weblate.org/"
|
||||
|
||||
MT_APERTIUM_APY = "http://172.16.0.9:2737/"
|
||||
MT_SERVICES += ('weblate.machinery.apertium.ApertiumAPYTranslation',)
|
||||
EOT
|
||||
|
||||
# Fill the database
|
||||
sudo -u weblate $WEBLATE_HOME/weblate-env/bin/weblate migrate
|
||||
sudo -u weblate $WEBLATE_HOME/weblate-env/bin/weblate changesite --set-name $WEBLATE_DOMAIN
|
||||
sudo -u weblate $WEBLATE_HOME/weblate-env/bin/weblate createadmin --username nijel --email michal@cihar.com --name 'Michal Čihař'
|
||||
if [ -n "$WEBLATE_PASSWORD" ] ; then
|
||||
sudo -u weblate $WEBLATE_HOME/weblate-env/bin/weblate createadmin --username nijel --email michal@cihar.com --name 'Michal Čihař' --password "$WEBLATE_PASSWORD"
|
||||
else
|
||||
sudo -u weblate $WEBLATE_HOME/weblate-env/bin/weblate createadmin --username nijel --email michal@cihar.com --name 'Michal Čihař'
|
||||
fi
|
||||
sudo -u weblate $WEBLATE_HOME/weblate-env/bin/weblate collectstatic --noinput
|
||||
|
||||
# Celery and uwsgi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue