mirror of
https://github.com/deajan/obackup.git
synced 2024-11-15 04:03:41 +01:00
76 lines
1.8 KiB
Bash
Executable File
76 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
## dev pre-processor bootstrap rev 2018032201
|
|
## Yeah !!! A really tech sounding name... In fact it's just include emulation in bash
|
|
|
|
function Usage {
|
|
echo "$0 - Quick and dirty preprocessor for including ofunctions into programs"
|
|
echo "Creates and executes $0.tmp.sh"
|
|
echo "Usage:"
|
|
echo ""
|
|
echo "$0 --program=osync|osync_target_helper|obackup|pmocr [options to pass to program]"
|
|
echo "Can also be run with BASHVERBOSE=YES environment variable in order to prefix program with bash -x"
|
|
}
|
|
|
|
|
|
if [ ! -f "./merge.sh" ]; then
|
|
echo "Plrase run bootstrap.sh from osync/dev directory."
|
|
exit 1
|
|
fi
|
|
|
|
bootstrapProgram=""
|
|
opts=""
|
|
outputFileName="$0"
|
|
|
|
for i in "$@"; do
|
|
case $i in
|
|
--program=*)
|
|
bootstrapProgram="${i##*=}"
|
|
;;
|
|
*)
|
|
opts=$opts" $i"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ "$bootstrapProgram" == "" ]; then
|
|
Usage
|
|
exit 128
|
|
else
|
|
source "merge.sh"
|
|
|
|
__PREPROCESSOR_PROGRAM=$bootstrapProgram
|
|
__PREPROCESSOR_PROGRAM_EXEC="n_$bootstrapProgram.sh"
|
|
__PREPROCESSOR_Constants
|
|
|
|
if [ ! -f "$__PREPROCESSOR_PROGRAM_EXEC" ]; then
|
|
echo "Cannot find file [n_$bootstrapProgram.sh]."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
cp "$__PREPROCESSOR_PROGRAM_EXEC" "$outputFileName.tmp.sh"
|
|
if [ $? != 0 ]; then
|
|
echo "Cannot copy original file [$__PREPROCESSOR_PROGRAM_EXEC] to [$outputFileName.tmp.sh]."
|
|
exit 1
|
|
fi
|
|
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
|
|
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "$outputFileName.tmp.sh"
|
|
done
|
|
chmod +x "$outputFileName.tmp.sh"
|
|
if [ $? != 0 ]; then
|
|
echo "Cannot make [$outputFileName] executable."
|
|
exit 1
|
|
fi
|
|
|
|
# Termux fix
|
|
if type termux-fix-shebang > /dev/null 2>&1; then
|
|
termux-fix-shebang "$outputFileName.tmp.sh"
|
|
fi
|
|
|
|
if [ "$BASH_VERBOSE" == "yes" ]; then
|
|
bash -x "$outputFileName.tmp.sh" $opts
|
|
else
|
|
"$outputFileName.tmp.sh" $opts
|
|
fi
|