Created
January 5, 2015 23:47
-
-
Save sofar/255eda1a109ec3ed4911 to your computer and use it in GitHub Desktop.
KSP autosave your persistent.sfs into a git tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# how to use: | |
# | |
# - packages required: inotify-tools, git | |
# - change SAVENAME into the name of your savegame (folder name) | |
# - cd into your savegame folder, and execute: | |
# git init | |
# git add * */* */*/* | |
# git commit -a --message "Initial Checkin." | |
# - place this script in your KSP folder and execute it | |
# | |
# Cheers! <sofar@foo-projects.org> | |
# change these if needed: | |
SAVENAME="career" | |
KSP=./KSP.x86_64 | |
# save just in case I've made any modifications | |
( | |
cd saves/$SAVENAME | |
git add * */* */*/* | |
git commit -a --message "." | |
) | |
# autosave loop | |
( | |
cd saves/$SAVENAME | |
while true ; do | |
inotifywait -e close_write persistent.sfs | |
if [ $? == 0 ]; then | |
git add persistent.sfs | |
git commit persistent.sfs --message "autosave $(date +%Y%m%d-%H%M%S)" | |
else | |
exit 1 | |
fi | |
done | |
) & | |
$KSP | |
# clean up background task at exit | |
kill `jobs -p` | |
# save all our ship modifications | |
( | |
cd saves/$SAVENAME | |
git add * */* */*/* | |
git commit -a --message "." | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment