From 8035d21a276fff3600e5952ebf1fba8b2d4fcd20 Mon Sep 17 00:00:00 2001
From: Luca Beltrame <lbeltrame@kde.org>
Date: Sat, 12 Mar 2016 18:37:37 +0100
Subject: [PATCH] Script to auto-copy l4d assets

---
 copy_l4d | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 copy_l4d

diff --git a/copy_l4d b/copy_l4d
new file mode 100644
index 0000000..67b0ed6
--- /dev/null
+++ b/copy_l4d
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -o nounset
+set -o pipefail
+set -o errexit
+
+watch_dir="/home/mod_exchange/"
+dest_dir="/home/mpluser/l4d2/game/left4dead2/addons/"
+
+function test_command {
+    "$@"
+    local status=$?
+    return $status
+}
+
+while true
+do
+        inotifywait --syslog -e close_write $watch_dir
+        for item in $watch_dir/*.zip
+        do
+                unzip -o ${item} -d ${watch_dir}
+        done
+        rm  $watch_dir/*.zip
+        rsync $watch_dir/* /home/mpluser/l4d2/game/left4dead2/addons/ --remove-source-files
+
+        if test_command systemctl is-active l4d
+        then
+                sudo systemctl restart l4d
+        fi
+
+done