summarylogtreecommitdiffstats
path: root/doukutsu
diff options
context:
space:
mode:
Diffstat (limited to 'doukutsu')
-rw-r--r--doukutsu50
1 files changed, 50 insertions, 0 deletions
diff --git a/doukutsu b/doukutsu
new file mode 100644
index 000000000000..daca8c5cb8b2
--- /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-fr
+USERDATADIR=$HOME/.doukutsu-fr
+
+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