diff options
author | Nascher | 2015-08-12 16:22:45 +0000 |
---|---|---|
committer | Nascher | 2015-08-12 16:22:45 +0000 |
commit | 9f15a739336c7114e0b13db2439ad9c3b029a104 (patch) | |
tree | 37902a9946629d6e1242781420193a254831fa49 /doukutsu | |
download | aur-9f15a739336c7114e0b13db2439ad9c3b029a104.tar.gz |
Initial import
Diffstat (limited to 'doukutsu')
-rw-r--r-- | doukutsu | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/doukutsu b/doukutsu new file mode 100644 index 000000000000..942dcbecccbf --- /dev/null +++ b/doukutsu @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# This script replicates the Doukutsu working folder in a specified directory +# (defaults to ~/.doukutsu) by creating symbolic links to the installed +# files. This allows the game to store saves and configuration files +# without write permissions in the install folder and lets every user on +# system keep their own saves/settings. It then launches the game or +# configuration tool. + +INSTALLDIR=/opt/doukutsu +USERDATADIR=$HOME/.doukutsu + +function create_structure { + mkdir -p $USERDATADIR + ln -s -t $USERDATADIR $INSTALLDIR/{doukutsu,doukutsu.bin,DoConfigure,data,doc} + cp $INSTALLDIR/Config.dat $USERDATADIR + cd $USERDATADIR +} + +function integrity_check { + USERFILECOUNT=`find $USERDATADIR -maxdepth 1 | grep -v Profile.dat | grep -v error.log | wc -l` + SYSTEMFILECOUNT=`find $INSTALLDIR -maxdepth 1 | grep -v Profile.dat | grep -v error.log | wc -l` + if [ $USERFILECOUNT != $SYSTEMFILECOUNT ]; + then create_structure; + fi +} + +while getopts "ch" options; do + case $options in + c) + integrity_check + cd $USERDATADIR + ./DoConfigure + exit 0;; + h|*) + printf "Usage: doukutsu [-h] [-c]\n" + exit 0;; + esac +done + +if [ -d $USERDATADIR ]; then + integrity_check + + cd $USERDATADIR + exec ./doukutsu $@ +else + create_structure + + exec ./doukutsu $@ +fi |