X-Git-Url: https://arthur.barton.de/gitweb/?p=appify.git;a=blobdiff_plain;f=appify.sh;h=a5fe28433598e62b369ea739bfbfdfc9aeb53040;hp=45c6ea2c75104dc7d3261bab03c9531da1da5d8a;hb=c1090d5e32eb32953f83a31749e7dc45b07fda7e;hpb=6106ca03cd41e11bf304fdf30bbc1c89d08d0c4c diff --git a/appify.sh b/appify.sh index 45c6ea2..a5fe284 100755 --- a/appify.sh +++ b/appify.sh @@ -1,7 +1,9 @@ #!/bin/bash # -# appify -- convert your non-interactive shell script into a Mac OS X application +# appify -- convert non-interactive shell script into Mac OS X applications # Copyright (C) 2010 Adam Backstrom +# Copyright (C) 2015 Alexander Barton +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -19,7 +21,7 @@ args=$(getopt h $*) function usage { - echo "Usage: $0 [-h] script.sh target.app" + echo "Usage: $0 [-h] " exit 2 } @@ -43,6 +45,8 @@ fi SCRIPT=$1 TARGET=$2 +BASENAME=`basename "$SCRIPT"` + if [ -e "$TARGET" ]; then echo "$TARGET exists, exiting" 1>&2 exit 3 @@ -59,8 +63,10 @@ fi # done checking args; create the app # -mkdir -p "$TARGET/Contents/MacOS" -mkdir -p "$TARGET/Contents/Resources" +umask 0022 + +mkdir -p "$TARGET/Contents/MacOS" || exit 1 +mkdir -p "$TARGET/Contents/Resources" || exit 1 cat <"$TARGET/Contents/Info.plist" @@ -68,7 +74,7 @@ cat <"$TARGET/Contents/Info.plist" CFBundleExecutable - run.sh + ${BASENAME} CFBundleIconFile CFBundleInfoDictionaryVersion @@ -83,5 +89,5 @@ cat <"$TARGET/Contents/Info.plist" EOF -cp "$SCRIPT" "$TARGET/Contents/MacOS/run.sh" -chmod 755 "$TARGET/Contents/MacOS/run.sh" +cp "$SCRIPT" "$TARGET/Contents/MacOS/$BASENAME" || exit 1 +chmod 755 "$TARGET/Contents/MacOS/$BASENAME" || exit 1