summarylogtreecommitdiffstats
path: root/doukutsu
diff options
context:
space:
mode:
authorNascher2015-08-12 16:22:45 +0000
committerNascher2015-08-12 16:22:45 +0000
commit9f15a739336c7114e0b13db2439ad9c3b029a104 (patch)
tree37902a9946629d6e1242781420193a254831fa49 /doukutsu
downloadaur-9f15a739336c7114e0b13db2439ad9c3b029a104.tar.gz
Initial import
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..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