X-Git-Url: https://arthur.barton.de/gitweb/?p=appify.git;a=blobdiff_plain;f=appify.sh;h=a7db78620f05e361fbf60059f9aff50c0beaf282;hp=ca8962f4357534942edc5ff7074f024294125ddb;hb=f23850b38ed51ecae95beda6fe796fdb92124ba1;hpb=334534e479cd496a286ce4020605071a98ff29b3 diff --git a/appify.sh b/appify.sh old mode 100644 new mode 100755 index ca8962f..a7db786 --- a/appify.sh +++ b/appify.sh @@ -1,28 +1,27 @@ #!/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 -# -# 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 (at your option) any later version. -# +# 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 +# (at your option) any later version. +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. args=$(getopt h $*) function usage { - echo "Usage: $0 [-h] script.sh target.app" + echo "Usage: $0 [-h] " exit 2 } @@ -46,8 +45,15 @@ fi SCRIPT=$1 TARGET=$2 -if [ -d "$TARGET" ]; then - echo "$TARGET exists, exiting" 1>&2 +BASENAME=`basename "$SCRIPT"` + +if [ ! -r "$SCRIPT" ]; then + echo "$SCRIPT isn't readable!" 1>&2 + exit 3 +fi + +if [ -e "$TARGET" ]; then + echo "$TARGET exists!" 1>&2 exit 3 fi @@ -62,8 +68,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" @@ -71,7 +79,7 @@ cat <"$TARGET/Contents/Info.plist" CFBundleExecutable - run.sh + ${BASENAME} CFBundleIconFile CFBundleInfoDictionaryVersion @@ -86,5 +94,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