--- branches/magellan-next/include/mtools.sminc 2011/06/02 20:44:40 7874 +++ trunk/include/mtools.sminc 2012/06/26 15:38:25 12653 @@ -169,10 +169,10 @@ fi # needed directory - install -d ${BINDIR}/etc/udev/rules.d || die + install -d ${BINDIR}/lib/udev/rules.d || die # install our udev rule - install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die + install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/udev/rules.d/${udevrule} || die } minstalludevhelper() @@ -468,7 +468,7 @@ # installs logrotate configuration files -# minstallpam /path/to/logrotatefile {destfilename} +# minstalllog /path/to/logrotatefile {destfilename} minstalllog() { local logfile @@ -636,7 +636,7 @@ # recursive if [[ $1 = -r ]] || [[ $1 = -R ]] then - opts="--recursive" + opts="-R" source="$2" dest="$3" fi @@ -644,7 +644,14 @@ # recursive if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] then - opts="--recursive --force" + opts="-R -f" + source="$2" + dest="$3" + fi + + if [[ $1 = -a ]] + then + opts="-a" source="$2" dest="$3" fi @@ -655,6 +662,31 @@ cp -v ${opts} ${source} ${BINDIR}/${dest} || die } +mdelete() +{ + local dest="$1" + local opts + + # recursive + if [[ $1 = -r ]] || [[ $1 = -R ]] + then + opts="-r" + dest="$2" + fi + + # recursive + if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] + then + opts="-r -f" + dest="$2" + fi + + [[ -z ${dest} ]] && die "No dest given." + [[ -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist." + + rm -v ${opts} ${BINDIR}/${dest} || die +} + mmove() { local source="$1" @@ -664,7 +696,7 @@ # force if [[ $1 = -f ]] then - opts="--force" + opts="-f" source="$2" dest="$3" fi @@ -710,7 +742,7 @@ # recursive if [[ $1 = -r ]] || [[ $1 = -R ]] then - local recursive="--recursive" + local recursive="-R" local owner="$2" local path="$3" fi @@ -730,7 +762,7 @@ # recursive if [[ $1 = -r ]] || [[ $1 = -R ]] then - local recursive="--recursive" + local recursive="-R" local posix="$2" local path="$3" fi @@ -762,9 +794,14 @@ { local unit local file + local prefix [[ -z "$1" ]] && die "No unit given" + # get the right prefix for newer systemd + [[ -x /bin/systemctl ]] && prefix="" + [[ -x /usr/bin/systemctl ]] && prefix="/usr" + # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then @@ -781,10 +818,10 @@ fi # needed directory - install -d ${BINDIR}/lib/systemd/system || die + install -d ${BINDIR}${prefix}/lib/systemd/system || die # install our initscript - install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/systemd/system/${unit} || die + install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}/lib/systemd/system/${unit} || die } # installs systemd tmp configs to /etc/tmpfiles.d @@ -815,5 +852,47 @@ install -d ${BINDIR}/etc/tmpfiles.d || die # install our tmpdfile - install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles./${tmpdfile} || die + install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die +} + +mclearconfig() +{ + local confdir + local prefix="${BINDIR}" + [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" + + # no bindir prefix if requested + case $1 in + -b|--no-bindir) prefix="";; + esac + + confdir="$(dirname ${MCONFIG})" + if [[ ! -d ${prefix}/${confdir} ]] + then + install -d ${prefix}/${confdir} || die + fi + : > ${prefix}/${MCONFIG} +} + +maddconfig() +{ + local argv="$1" + local confdir + local prefix="${BINDIR}" + + [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" + + # no bindir prefix if requested + case $1 in + -b|--no-bindir) prefix=""; argv="$2" ;; + esac + + [[ -z ${argv} ]] && die "No argument given!" + + confdir="$(dirname ${MCONFIG})" + if [[ ! -d ${prefix}/${confdir} ]] + then + install -d ${prefix}/${confdir} || die + fi + echo "${argv}" >> ${prefix}/${MCONFIG} || die }