Tue, 25 Jul 2023 17:18:53 +0200
add error handling to install.sh
fixes #273
dist/install.sh | file | annotate | diff | comparison | revisions |
--- a/dist/install.sh Sun Jul 16 13:29:41 2023 +0200 +++ b/dist/install.sh Tue Jul 25 17:18:53 2023 +0200 @@ -10,6 +10,13 @@ echo "Default PREFIX: /usr/local" } +# error function +exit_on_error() +{ + echo "$1" + exit 1 +} + # # parse arguments # @@ -22,13 +29,25 @@ esac done -echo "mkdir -p $PREFIX/lib/uwproj" -mkdir -p "$PREFIX/lib/uwproj" +# +# create install dir +# +echo "mkdir -p $PREFIX/lib/uwproj $PREFIX/bin" +mkdir -p "$PREFIX/lib/uwproj" "$PREFIX/bin" \ + || exit_on_error "Creating install directory failed." +# +# install the JAR file +# echo "cp ../target/uwproj-0.1-jar-with-dependencies.jar $PREFIX/lib/uwproj/uwproj-0.1.jar" -cp "../target/uwproj-0.1-jar-with-dependencies.jar" "$PREFIX/lib/uwproj/uwproj-0.1.jar" +cp "../target/uwproj-0.1-jar-with-dependencies.jar" "$PREFIX/lib/uwproj/uwproj-0.1.jar" \ + || exit_on_error "Installing JAR file failed." +# +# create a run script in the bin dir +# echo "cp bin/uwproj $PREFIX/bin" -sed "s:%%PREFIX%%:$PREFIX:g" "bin/uwproj" > "$PREFIX/bin/uwproj" +sed "s:%%PREFIX%%:$PREFIX:g" "bin/uwproj" > "$PREFIX/bin/uwproj" \ + || exit_on_error "Creating run script failed."