mirror of
https://gh.llkk.cc/https://github.com/WeblateOrg/scripts.git
synced 2025-10-03 15:01:00 +08:00
improve remote install
This commit is contained in:
parent
1eb673c927
commit
f3910f7167
4 changed files with 32 additions and 4 deletions
|
@ -2,6 +2,11 @@
|
|||
|
||||
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
|
||||
fi
|
||||
echo "Weblate title:"
|
||||
read -r title
|
||||
if [ -f ~/.config/weblate-bootstrap/sentry_dsn ] ; then
|
||||
|
@ -29,6 +34,7 @@ smtp_pass=$(openssl rand -hex 32)
|
|||
|
||||
cat > "${1:-/etc/weblate-bootstrap}" <<EOT
|
||||
WEBLATE_DOMAIN="$domain"
|
||||
WEBLATE_CLOUD_DOMAIN="$cloud_domain"
|
||||
WEBLATE_TITLE="$title"
|
||||
WEBLATE_SECRET=$(openssl rand -hex 32)
|
||||
WEBLATE_SENTRY="$sentry"
|
||||
|
|
15
dns-edit
Executable file
15
dns-edit
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
import CloudFlare
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
raise ValueError("Usage: dns-edit IPV4 IPV6 NAME")
|
||||
|
||||
cf = CloudFlare.CloudFlare()
|
||||
zone = cf.zones.get(params={"name": "weblate.cloud"})[0]
|
||||
zone_id = zone['id']
|
||||
zone_name = zone['name']
|
||||
print("editing zone_id=%s zone_name=%s" % (zone_id, zone_name))
|
||||
|
||||
cf.zones.dns_records.post(zone_id, data={'name':sys.argv[3], 'type':'A', 'content':sys.argv[1]})
|
||||
cf.zones.dns_records.post(zone_id, data={'name':sys.argv[3], 'type':'AAAA', 'content':sys.argv[2]})
|
|
@ -8,6 +8,8 @@ if [ -z "$1" ] || [ "$1" = "--help" ] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
SERVER_NAME="$1"
|
||||
|
||||
# Set path to include script directory
|
||||
PATH="$(dirname "$(readlink -f "$0")"):$PATH"
|
||||
export PATH
|
||||
|
@ -25,21 +27,25 @@ EOT
|
|||
. "$BOOTSTRAP"
|
||||
|
||||
# Create server
|
||||
# TODO: decide cx21 / cax11 / cax21
|
||||
# Location: nbg1 / fsn1
|
||||
# image is debian-12 for arm64
|
||||
hcloud server create \
|
||||
--image 114690389 \
|
||||
--location fsn1 \
|
||||
--name "$1" \
|
||||
--name "$SERVER_NAME" \
|
||||
--network 19990 \
|
||||
--firewall 13110 \
|
||||
--ssh-key 1056953 \
|
||||
--ssh-key 1494306 \
|
||||
--type cax11 | tee "$TMPFILE"
|
||||
|
||||
# TODO: decide cx21 / cax11 / cax21
|
||||
# Location: nbg1 / fsn1
|
||||
|
||||
IPADDRESS=$(sed -n 's/IPv4: \(.*\)/\1/p' "$TMPFILE")
|
||||
IP6ADDRESS=$(sed -n 's/IPv6: \(.*\)/\1/p' "$TMPFILE")
|
||||
|
||||
hcloud server set-rdns --ip "$IPADDRESS" --hostname "$WEBLATE_DOMAIN" "$SERVER_NAME"
|
||||
hcloud server set-rdns --ip "$IP6ADDRESS" --hostname "$WEBLATE_DOMAIN" "$SERVER_NAME"
|
||||
./dns-edit "$IPADDRESS" "$IP6ADDRESS" "$WEBLATE_CLOUD_DOMAIN"
|
||||
|
||||
ssh-keygen -f ~/.ssh/known_hosts -R "$IPADDRESS"
|
||||
|
||||
|
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
cloudflare==2.17.0
|
Loading…
Add table
Add a link
Reference in a new issue