diff --git a/update.sh b/update.sh
index 6382ca3020528023a3af5608b5be5eacf7373bac..e93253aa4cb80742cebf38408ecdf7ec0f2388ed 100755
--- a/update.sh
+++ b/update.sh
@@ -7,10 +7,16 @@ echo "reset target is $target"
 # update meta repo
 git fetch origin "$target"
 # use the latest commit on master, discard any local changes
-git reset --hard "$target"
+git reset --hard "origin/$target"
 # sync repo urls
 git submodule sync --recursive
 # update commits, discard any local changes
 git submodule update --init --recursive --force
 # remove unversioned files
 git clean -dff
+
+
+[ -d advtrains_luaautomation_sync ] &&
+advtrains_luaautomation_sync/clean.sh &&
+cp -r advtrains/advtrains_luaautomation advtrains_luaautomation_sync/patched &&
+advtrains_luaautomation_sync/apply_patch.sh