diff --git a/fastdl_sync/r2_update.sh b/fastdl_sync/r2_update.sh new file mode 100644 index 0000000..464ead0 --- /dev/null +++ b/fastdl_sync/r2_update.sh @@ -0,0 +1,49 @@ +#!/usr/bin/sh +#run full reclone when arguement is given +if [ $# -eq 1 ] + then + echo 'doing long run with all files being updated.' + #ZE server + rclone copy /home/gameservers/fastdl/css_ze/materials r2demo:/css_ze/materials/ + rclone copy /home/gameservers/fastdl/css_ze/models r2demo:/css_ze/models/ + rclone copy /home/gameservers/fastdl/css_ze/maps r2demo:/css_ze/maps/ + rclone copy /home/gameservers/fastdl/css_ze/sound r2demo:/css_ze/sound/ + #ZR server + rclone copy /home/gameservers/fastdl/css_zr/materials r2demo:/css_zr/materials/ + rclone copy /home/gameservers/fastdl/css_zr/models r2demo:/css_zr/models/ + rclone copy /home/gameservers/fastdl/css_zr/maps r2demo:/css_zr/maps/ + rclone copy /home/gameservers/fastdl/css_zr/sound r2demo:/css_zr/sound/ + #MG server + rclone copy /home/gameservers/fastdl/css_mg/materials r2demo:/css_mg/materials/ + rclone copy /home/gameservers/fastdl/css_mg/models r2demo:/css_mg/models/ + rclone copy /home/gameservers/fastdl/css_mg/maps r2demo:/css_mg/maps/ + rclone copy /home/gameservers/fastdl/css_mg/sound r2demo:/css_mg/sound/ + #svencoop + rclone copy /home/gameservers/fastdl/svencoop/svencoop_addon r2demo:/svencoop/ + #gmod zs + rclone copy --no-update-modtime /home/gameservers/fastdl/gmod_zs/maps r2demo:/gmod_zs/maps/ + echo 'Finished long run with all files updated.' +#else if no arguement given run default with 30minute maximum. +else + echo 'doing short run with files younger than 30 minutes.' + #ZE server + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/materials r2demo:/css_ze/materials/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/models r2demo:/css_ze/models/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/maps r2demo:/css_ze/maps/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_ze/sound r2demo:/css_ze/sound/ + #ZR server + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/materials r2demo:/css_zr/materials/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/models r2demo:/css_zr/models/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/maps r2demo:/css_zr/maps/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_zr/sound r2demo:/css_zr/sound/ + #MG server + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/materials r2demo:/css_mg/materials/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/models r2demo:/css_mg/models/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/maps r2demo:/css_mg/maps/ + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/css_mg/sound r2demo:/css_mg/sound/ + #svencoop + rclone copy --max-age 30m --no-traverse /home/gameservers/fastdl/svencoop/svencoop_addon r2demo:/svencoop/ + #gmod zs + rclone copy --max-age 30m --no-traverse --no-update-modtime /home/gameservers/fastdl/gmod_zs/maps r2demo:/gmod_zs/maps/ + echo 'Finished short run with files younger than 30 minutes.' +fi diff --git a/fastdl_sync/run-docker-cp.py b/fastdl_sync/run-docker-cp.py new file mode 100644 index 0000000..1e591d4 --- /dev/null +++ b/fastdl_sync/run-docker-cp.py @@ -0,0 +1,35 @@ +#!/usr/local/bin/python3.5 + +import subprocess + +def compare_lists(docker_find, ovh_find): + d = [] + for file_docker in docker_find: + file_name_docker = str(file_docker).split("/", -1)[-1].replace("'", '') + found = False + for file_ovh in ovh_find: + file_name_ovh = str(file_ovh).split("/", -1)[-1].replace("'", '') + if file_name_ovh == file_name_docker: + found = True + break + if not found: + d.append(file_docker) + return d + +def files_to_move(files): + for file in files: + file = file.decode("utf-8") str1 = f"docker cp debian-server:{file} ../gmod_zs/fastdl/maps/" + #print(str1) + subprocess.Popen([str1], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] + +if __name__ == "__main__": + #find maps in docker + docker_find = subprocess.Popen(["docker exec debian-server find /home/gameservers_zs/gmod_zs_1/garrysmod/maps -type f"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).communicate()[0].splitlines() + #find maps on our OVH machine + ovh_find = subprocess.Popen(["find /home/gameservers/gmod_zs/fastdl/maps/ -type f"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).communicate()[0].splitlines() + #if maps are in docker but not OVH we need to list them + maps_to_move = compare_lists(docker_find, ovh_find) + #move the files to OVH. + files_to_move(maps_to_move) + + diff --git a/fastdl_sync/run-fastdl.sh b/fastdl_sync/run-fastdl.sh index 638c3e1..d669153 100755 --- a/fastdl_sync/run-fastdl.sh +++ b/fastdl_sync/run-fastdl.sh @@ -5,9 +5,11 @@ screen -S fastdl_css_ze_uk -X quit screen -S fastdl_css_zr_uk -X quit screen -S fastdl_css_mg_uk -X quit screen -S fastdl_svencoop_uk -X quit +screen -S fastdl_gmod_zs_uk -X quit #uk 2024 screen -A -m -d -S fastdl_css_ze_uk python3 fastdl_ftp_uk.py -t 2 ../css_ze/cstrike/{maps,materials,models,sound} ftp://127.0.0.1/fastdl/css_ze screen -A -m -d -S fastdl_css_zr_uk python3 fastdl_ftp_uk.py -t 2 ../css_zr/cstrike/{maps,materials,models,sound} ftp://127.0.0.1/fastdl/css_zr screen -A -m -d -S fastdl_css_mg_uk python3 fastdl_ftp_uk.py -t 2 ../css_mg/cstrike/{maps,materials,models,sound} ftp://127.0.0.1/fastdl/css_mg -screen -A -m -d -S fastdl_svencoop_uk python3 fastdl_ftp_uk_sven.py -t 2 ../svencoop/svencoop_addon/ ftp://127.0.0.1/fastdl/svencoop +screen -A -m -d -S fastdl_svencoop_uk python3 fastdl_ftp_uk_sven.py -t 2 ../svencoop/svencoop_addon/ ftp://127.0.0.1/fastdl/svencoop +screen -A -m -d -S fastdl_gmod_zs_uk python3 fastdl_ftp_uk.py -t 2 ../gmod_zs/fastdl/{maps,materials,models,sound} ftp://127.0.0.1/fastdl/gmod_zs