Auto reset local changes, add update script

This commit is contained in:
TNE 2022-11-26 05:53:02 +01:00
parent 43c3d64438
commit 4476f94602
5 changed files with 60 additions and 11 deletions

View File

@ -27,6 +27,12 @@ services:
- 21027:21027/udp
restart: ${RESTART:-unless-stopped}
chaotic-management:
container_name: chaotic-management
restart: ${RESTART:-unless-stopped}
image: nginx
entrypoint: "/bin/sh -c 'trap exit TERM; sleep 10; while :; do curl -X POST -H \"X-API-Key: ${SYNCTHING_API_KEY:-XYZ}\" http://syncthing:8384/rest/db/revert?folder=jhcrt-m2dra; sleep 1h & wait $${!}; done;'"
cloudflared:
image: erisamoe/cloudflared:latest
container_name: cloudflared

View File

@ -36,6 +36,12 @@ services:
- 21027:21027/udp
restart: ${RESTART:-unless-stopped}
chaotic-management:
container_name: chaotic-management
restart: ${RESTART:-unless-stopped}
image: nginx
entrypoint: "/bin/sh -c 'trap exit TERM; sleep 10; while :; do curl -X POST -H \"X-API-Key: ${SYNCTHING_API_KEY:-XYZ}\" http://syncthing:8384/rest/db/revert?folder=jhcrt-m2dra; sleep 1h & wait $${!}; done;'"
certbot:
image: certbot/certbot:${LETSENCRYPT_TAG:-latest}
container_name: certbot

View File

@ -1,22 +1,16 @@
<configuration version="35">
<folder id="jhcrt-m2dra" label="Chaotic AUR Repository" path="/repo" type="receiveonly" rescanIntervalS="3600" fsWatcherEnabled="false" fsWatcherDelayS="10" ignorePerms="true" autoNormalize="true">
<filesystemType>basic</filesystemType>
<device id="ZDHVMSP-EW4TMWX-DBH2W4P-HV5A6OY-BBEFABO-QTENANJ-RJ6GKNX-6KCG7QY" introducedBy="">
<encryptionPassword></encryptionPassword>
</device>
<device id="ZDHVMSP-EW4TMWX-DBH2W4P-HV5A6OY-BBEFABO-QTENANJ-RJ6GKNX-6KCG7QY" introducedBy=""></device>
<order>oldestFirst</order>
</folder>
<device id="ZDHVMSP-EW4TMWX-DBH2W4P-HV5A6OY-BBEFABO-QTENANJ-RJ6GKNX-6KCG7QY" name="builds.garudalinux.org" compression="metadata" introducer="true" skipIntroductionRemovals="false" introducedBy="">
<address>tcp://builds.garudalinux.org</address>
<address>dynamic</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
<untrusted>false</untrusted>
<remoteGUIPort>0</remoteGUIPort>
</device>
<gui enabled="true" tls="false" debugging="false">
<address>127.0.0.1:8384</address>
<apikey></apikey>
</gui>
</configuration>

10
run
View File

@ -25,6 +25,11 @@ fi
source .env
if [[ ! -v SYNCTHING_API_KEY ]]; then
SYNCTHING_API_KEY="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)"
echo "SYNCTHING_API_KEY=$SYNCTHING_API_KEY" >> ./.env
fi
if [ "$USE_TUNNELS" != "true" ]; then
if [ ! -e ./data/letsencrypt/etc/renewal/chaotic.conf ]; then
docker run -p 80:80 -p 443:443 --rm -v "$PWD/data/letsencrypt/etc:/etc/letsencrypt" -v "$PWD/data/letsencrypt/var:/var/lib/letsencrypt" certbot/certbot:${LETSENCRYPT_TAG:-latest} certonly --standalone --non-interactive --agree-tos --cert-name chaotic -n -m "$EMAIL" -d "$DOMAIN_NAME"
@ -53,10 +58,11 @@ if [ ! -e ./data/syncthing/config.xml ]; then
chown -R 1000:1000 ./data/syncthing
fi
sed -i -r '/<device id="ZDHVMSP-EW4TMWX-DBH2W4P-HV5A6OY-BBEFABO-QTENANJ-RJ6GKNX-6KCG7QY"/! s|(^ *<device .*id="[^"]+".*skipIntroductionRemovals="false".*introducedBy=")(">)|\1ZDHVMSP-EW4TMWX-DBH2W4P-HV5A6OY-BBEFABO-QTENANJ-RJ6GKNX-6KCG7QY\2|' ./data/syncthing/config.xml
sed -i -r "s|(<apikey>).*(</apikey>)|\1$SYNCTHING_API_KEY\2|" ./data/syncthing/config.xml
if [ "$USE_TUNNELS" != "true" ]; then
docker-compose -f docker-compose.yml pull
docker-compose -f docker-compose.yml up ${COMPOSEFLAGS-"-d"}
else
docker-compose -f docker-compose-tunnels.yml pull
docker-compose -f docker-compose-tunnels.yml up ${COMPOSEFLAGS-"-d"}
fi

37
update Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -e
if [[ $EUID -ne 0 ]]; then
echo Run as root!
exit 1
fi
./stop
if [ ! -d "./.git" ]; then
if [ "$(git rev-parse --is-inside-work-tree)" == "true" ]; then
echo "Please run this script in the main directory"
exit 1
fi
git init --initial-branch=main
git remote add origin https://github.com/chaotic-aur/docker-mirror
git fetch
git reset --hard origin/main
else
git pull || echo "Git pull failed, please fix the issue at hand."
fi
if [ "$SELFUPDATE" != 1 ]; then
SELFUPDATE=1 ./update
fi
source .env
if [ "$USE_TUNNELS" != "true" ]; then
docker-compose -f docker-compose.yml pull
else
docker-compose -f docker-compose-tunnels.yml pull
fi
./run