#!/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