Compare commits

...

5 Commits

Author SHA1 Message Date
drunkendog 21e3f1fc24 Fix typo in shebang 2023-08-25 23:10:27 +01:00
drunkendog daa3eeb2a0 Add backup/fetch-borg-latest.sh 2023-08-25 23:05:43 +01:00
drunkendog 72bbffede2 Allow relaunch-docker to be run in any directory 2023-08-25 22:51:17 +01:00
drunkendog bf71600bec Add post-pull.sh 2023-08-25 19:56:37 +01:00
drunkendog 938cdb45a3 Modify relaunch-docker, restrict directories from having .. in name
Strip newlines in relaunch-docker, add shebang and make relaunch-docker executable
2023-08-25 19:51:03 +01:00
4 changed files with 24 additions and 5 deletions

View File

@ -0,0 +1,6 @@
#!/bin/sh
set -e
wget -4 -O /usr/local/bin/borg-linux64 $(curl -s https://api.github.com/repos/borgbackup/borg/releases/latest| jq -r '.assets | .[] | select(.name == "borg-linux64") | .browser_download_url')
chmod -v +x /usr/local/bin/borg-linux64

4
post-pull.sh Normal file
View File

@ -0,0 +1,4 @@
cd "${0%/*}"
cd scripts
python3 setup-generator.py

View File

@ -1,4 +1,4 @@
#/bin/sh #!/bin/sh
systemctl stop nginx systemctl stop nginx
certbot certonly -n --standalone --agree-tos -d $1 -m $2 certbot certonly -n --standalone --agree-tos -d $1 -m $2

View File

@ -1,4 +1,7 @@
import glob, importlib, sys import glob
import importlib
import sys
import subprocess
with open("setup-template.py", "r") as f: with open("setup-template.py", "r") as f:
setup_template = f.read() setup_template = f.read()
@ -9,6 +12,9 @@ if len(sys.argv) >= 2:
directories = sys.argv[1:] directories = sys.argv[1:]
for directory in directories: for directory in directories:
if ".." in directory:
raise OSError("Illegal directory path")
if not glob.glob(f"{directory}/manifest.dat"): if not glob.glob(f"{directory}/manifest.dat"):
continue continue
@ -26,10 +32,13 @@ for directory in directories:
if replacement[0] == "#service": if replacement[0] == "#service":
with open(f"{directory}/relaunch-docker.sh", "w") as f: with open(f"{directory}/relaunch-docker.sh", "w") as f:
f.write(f"docker pull $(docker inspect {replacement[1]} | jq -r '.[0].Config.Image')\n") f.write("#!/bin/sh\n")
f.write(f"docker stop {replacement[1]}\n") f.write("cd \"${0%/*}\"\n")
f.write(f"docker rm {replacement[1]}\n") f.write(f"docker pull $(docker inspect {replacement[1].strip()} | jq -r '.[0].Config.Image')\n")
f.write(f"docker stop {replacement[1].strip()}\n")
f.write(f"docker rm {replacement[1].strip()}\n")
f.write(f"sh launch-docker.sh\n") f.write(f"sh launch-docker.sh\n")
subprocess.run(["chmod", "+x", f"{directory}/relaunch-docker.sh"])
if glob.glob(f"{directory}/parser.py"): if glob.glob(f"{directory}/parser.py"):
should_continue = input(f"Custom instructions found in {directory}, continue? (Y/N) ") should_continue = input(f"Custom instructions found in {directory}, continue? (Y/N) ")