Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repos:
hooks:
- id: actionlint
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.11.0-1
rev: v3.12.0-1
hooks:
- id: shfmt
- repo: https://github.com/adamchainz/blacken-docs
Expand Down
24 changes: 12 additions & 12 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ echo "Weblate domain:"
read -r domain
cloud_domain="${domain%.weblate.cloud}"
if [ "$cloud_domain" = "$domain" ]; then
echo "Cloud domain (without .weblate.cloud):"
read -r cloud_domain
echo "Cloud domain (without .weblate.cloud):"
read -r cloud_domain
fi
echo "Weblate title:"
read -r title
if [ -f ~/.config/weblate-bootstrap/sentry_dsn ]; then
sentry=$(cat ~/.config/weblate-bootstrap/sentry_dsn)
sentry=$(cat ~/.config/weblate-bootstrap/sentry_dsn)
else
echo "Sentry DSN:"
read -r sentry
echo "Sentry DSN:"
read -r sentry
fi
if [ -f ~/.config/weblate-bootstrap/sentry_token ]; then
sentry_token=$(cat ~/.config/weblate-bootstrap/sentry_token)
sentry_token=$(cat ~/.config/weblate-bootstrap/sentry_token)
else
echo "Sentry Token:"
read -r sentry_token
echo "Sentry Token:"
read -r sentry_token
fi
if [ -f ~/.config/weblate-bootstrap/graylog_token ]; then
graylog_token=$(cat ~/.config/weblate-bootstrap/graylog_token)
graylog_token=$(cat ~/.config/weblate-bootstrap/graylog_token)
else
echo "Graylog Token:"
read -r graylog_token
echo "Graylog Token:"
read -r graylog_token
fi

smtp_pass=$(openssl rand -hex 32)

cat > "${1:-/etc/weblate-bootstrap}" << EOT
cat >"${1:-/etc/weblate-bootstrap}" <<EOT
WEBLATE_DOMAIN="$domain"
WEBLATE_CLOUD_DOMAIN="$cloud_domain"
WEBLATE_TITLE="$title"
Expand Down
2 changes: 1 addition & 1 deletion configure-system
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apt update
apt install -y fail2ban vim
apt purge -y vim-tiny cryptsetup-initramfs

cat > /etc/fail2ban/jail.d/sshd.conf << EOT
cat >/etc/fail2ban/jail.d/sshd.conf <<EOT
[sshd]
mode = aggressive
EOT
Expand Down
28 changes: 14 additions & 14 deletions create-monitor-user
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ KEY="$(sed -n '/^env.KEY/ s/^env.KEY \(.*\)/\1/p' /etc/munin/plugin-conf.d/webla
SERVER="$(sed -n '/^env.SERVER/ s/^env.SERVER \(.*\)/\1/p' /etc/munin/plugin-conf.d/weblate_servers)"

if [ -z "$SERVER" ]; then
echo "Missing server configuration!"
exit 1
echo "Missing server configuration!"
exit 1
fi

if [ -n "$KEY" ]; then
if ! curl -f -s -H "Authorization: Token $KEY" "${SERVER}api/metrics/" -o /dev/null; then
echo "Key not working, recreating"
KEY=""
fi
if ! curl -f -s -H "Authorization: Token $KEY" "${SERVER}api/metrics/" -o /dev/null; then
echo "Key not working, recreating"
KEY=""
fi
fi

if [ -z "$KEY" ]; then

echo "Generating new key"
if [ -f "/home/weblate/weblate/docker-compose.override.yml" ]; then
cd /home/weblate/weblate || exit 1
KEY="$(sudo -u weblate docker compose exec --user weblate weblate weblate shell --no-imports -c 'from weblate.auth.models import User; user = User.objects.get_or_create(username="monitor")[0]; print(user.auth_token.key)')"
else
KEY="$(sudo -u weblate /home/weblate/weblate-env/bin/weblate shell --no-imports -c 'from weblate.auth.models import User; user = User.objects.get_or_create(username="monitor")[0]; print(user.auth_token.key)')"
fi
echo "Generating new key"
if [ -f "/home/weblate/weblate/docker-compose.override.yml" ]; then
cd /home/weblate/weblate || exit 1
KEY="$(sudo -u weblate docker compose exec --user weblate weblate weblate shell --no-imports -c 'from weblate.auth.models import User; user = User.objects.get_or_create(username="monitor")[0]; print(user.auth_token.key)')"
else
KEY="$(sudo -u weblate /home/weblate/weblate-env/bin/weblate shell --no-imports -c 'from weblate.auth.models import User; user = User.objects.get_or_create(username="monitor")[0]; print(user.auth_token.key)')"
fi

sed -i "s/^env.KEY .*/env.KEY $KEY/" /etc/munin/plugin-conf.d/weblate_servers
sed -i "s/^env.KEY .*/env.KEY $KEY/" /etc/munin/plugin-conf.d/weblate_servers
fi
24 changes: 12 additions & 12 deletions install-docker
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
apt-get update

apt-get install -y \
ca-certificates \
curl \
gnupg \
apparmor \
lsb-release
ca-certificates \
curl \
gnupg \
apparmor \
lsb-release

# Keyring
# shellcheck disable=SC2174
Expand All @@ -18,14 +18,14 @@ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o

# APT source
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') \
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') \
$(lsb_release -cs) stable" >/etc/apt/sources.list.d/docker.list

# Install Docker
apt-get update
apt-get install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
12 changes: 6 additions & 6 deletions install-exim
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ set -e
apt install -y exim4

sed -i \
-e "s#dc_eximconfig_configtype=.*#dc_eximconfig_configtype='satellite'#" \
-e "s#dc_local_interfaces=.*#dc_local_interfaces='127.0.0.1'#" \
-e "s#dc_readhost=.*#dc_readhost='$WEBLATE_DOMAIN'#" \
-e "s#dc_smarthost=.*#dc_smarthost='172.16.0.84'#" \
-e "s#dc_hide_mailname=.*#dc_hide_mailname='true'#" \
/etc/exim4/update-exim4.conf.conf
-e "s#dc_eximconfig_configtype=.*#dc_eximconfig_configtype='satellite'#" \
-e "s#dc_local_interfaces=.*#dc_local_interfaces='127.0.0.1'#" \
-e "s#dc_readhost=.*#dc_readhost='$WEBLATE_DOMAIN'#" \
-e "s#dc_smarthost=.*#dc_smarthost='172.16.0.84'#" \
-e "s#dc_hide_mailname=.*#dc_hide_mailname='true'#" \
/etc/exim4/update-exim4.conf.conf

#cat >> /etc/exim4/passwd.client <<EOT
#mail.cihar.com:$WEBLATE_DOMAIN:$EXIM_PASS
Expand Down
6 changes: 3 additions & 3 deletions install-graylog
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
set -e

if [ -n "$1" ]; then
WEBLATE_GRAYLOG_TOKEN="$1"
WEBLATE_GRAYLOG_TOKEN="$1"
else
# shellcheck disable=SC1091
. /etc/weblate-bootstrap
# shellcheck disable=SC1091
. /etc/weblate-bootstrap
fi

# Install package
Expand Down
10 changes: 5 additions & 5 deletions install-mail-delivery
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -e

if [ -z "$1" ] || [ "$1" = "--help" ]; then
echo "Usage: install-mail-delivery HOSTNAME"
exit 1
echo "Usage: install-mail-delivery HOSTNAME"
exit 1
fi

ssh "$1" apt update
Expand All @@ -20,7 +20,7 @@ scp ~/Nextcloud/Weblate/Servers/Mail/DKIM/dkim.private.key "$1":/etc/exim4/dkim.
ssh "$1" chgrp Debian-exim /etc/exim4/dkim.private.key
ssh "$1" chmod 640 /etc/exim4/dkim.private.key

ssh "$1" tee /etc/exim4/update-exim4.conf.conf << EOT
ssh "$1" tee /etc/exim4/update-exim4.conf.conf <<EOT
dc_eximconfig_configtype='internet'
dc_other_hostnames=''
dc_local_interfaces=''
Expand All @@ -36,7 +36,7 @@ dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
EOT

ssh "$1" tee /etc/exim4/conf.d/main/00_local_settings << EOT
ssh "$1" tee /etc/exim4/conf.d/main/00_local_settings <<EOT
daemon_smtp_ports = 25 : 587
REMOTE_SMTP_HELO_DATA = md.weblate.org
MAIN_HARDCODE_PRIMARY_HOSTNAME = md.weblate.org
Expand All @@ -55,7 +55,7 @@ ssh "$1" systemctl restart exim4
ssh "$1" ./scripts/install-graylog "'$(cat ~/.config/weblate-bootstrap/graylog_token)'"

# shellcheck disable=SC2087
ssh "$1" mail -r "noreply@weblate.org" -s "Test" -- "michal@weblate.org" << EOT
ssh "$1" mail -r "noreply@weblate.org" -s "Test" -- "michal@weblate.org" <<EOT
E-mail delivery from $1.

--
Expand Down
6 changes: 3 additions & 3 deletions install-munin
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export PATH

# Munin
mkdir -p /etc/munin/plugin-conf.d/
cat > /etc/munin/plugin-conf.d/postgres << EOT
cat >/etc/munin/plugin-conf.d/postgres <<EOT
[postgres_*]
user weblate
env.PGHOST 127.0.0.1
env.PGUSER weblate
env.PGPASSWORD weblate
EOT
cat > /etc/munin/plugin-conf.d/redis << EOT
cat >/etc/munin/plugin-conf.d/redis <<EOT
[redis]
env.host1 127.0.0.1
env.port1 6379
Expand All @@ -31,7 +31,7 @@ wget https://raw.githubusercontent.com/munin-monitoring/contrib/master/plugins/r
wget https://raw.githubusercontent.com/WeblateOrg/munin/master/weblate
wget https://raw.githubusercontent.com/WeblateOrg/munin/master/ksm
chmod +x redis weblate ksm
cat > /etc/munin/plugin-conf.d/weblate_servers << EOT
cat >/etc/munin/plugin-conf.d/weblate_servers <<EOT
[weblate]
env.SERVER https://$WEBLATE_DOMAIN/
env.KEY
Expand Down
30 changes: 15 additions & 15 deletions install-remote
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
set -e

if [ ! -f .venv/bin/activate ]; then
echo "Missing virtual environment!"
exit 2
echo "Missing virtual environment!"
exit 2
fi

if [ -z "$1" ] || [ "$1" = "--help" ]; then
echo "Usage: install-remote HOSTNAME [VERSION]"
exit 1
echo "Usage: install-remote HOSTNAME [VERSION]"
exit 1
fi

SERVER_NAME="$1"
Expand All @@ -24,7 +24,7 @@ TMPFILE=$(mktemp --tmpdir weblate-log.XXXXXXXXXX)

# Gather basic configuration
bootstrap "$BOOTSTRAP" "$2"
cat >> "$BOOTSTRAP" << EOT
cat >>"$BOOTSTRAP" <<EOT
WEBLATE_PASSWORD="$(apg -a 0 -M sncl -n 1 -x 10 -m 20)"
EOT

Expand All @@ -42,14 +42,14 @@ pip install -r requirements.txt
# debian-12 arm64: 114690389
# debian-12 amd64: 114690387
hcloud server create \
--image 114690389 \
--location fsn1 \
--name "$SERVER_NAME" \
--network 19990 \
--firewall 13110 \
--ssh-key 1056953 \
--ssh-key 1494306 \
--type cax11 | tee "$TMPFILE"
--image 114690389 \
--location fsn1 \
--name "$SERVER_NAME" \
--network 19990 \
--firewall 13110 \
--ssh-key 1056953 \
--ssh-key 1494306 \
--type cax11 | tee "$TMPFILE"

IPADDRESS=$(sed -n 's/IPv4: \(.*\)/\1/p' "$TMPFILE")
IP6ADDRESS=$(sed -n 's/IPv6: \(.*\)/\1/p' "$TMPFILE")
Expand All @@ -65,8 +65,8 @@ echo "Created server with address $IPADDRESS, please ensure $WEBLATE_DOMAIN poin
read -r dummy

s() {
# shellcheck disable=SC2029
ssh "root@$IPADDRESS" "$@"
# shellcheck disable=SC2029
ssh "root@$IPADDRESS" "$@"
}

# Configure mail sending
Expand Down
Loading