]> arthur.barton.de Git - appify.git/blobdiff - appify.sh
Break on errors (exit code 1)
[appify.git] / appify.sh
old mode 100644 (file)
new mode 100755 (executable)
index ca8962f..d0bb922
--- a/appify.sh
+++ b/appify.sh
@@ -1,23 +1,20 @@
 #!/bin/bash
-
 #
 # appify -- convert your non-interactive shell script into a Mac OS X application
 # 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.
-# 
+# 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 $*)
 
@@ -46,7 +43,9 @@ fi
 SCRIPT=$1
 TARGET=$2
 
-if [ -d "$TARGET" ]; then
+BASENAME=`basename "$SCRIPT"`
+
+if [ -e "$TARGET" ]; then
     echo "$TARGET exists, exiting" 1>&2
     exit 3
 fi
@@ -62,8 +61,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 <<EOF >"$TARGET/Contents/Info.plist"
 <?xml version="1.0" encoding="UTF-8"?>
@@ -71,7 +72,7 @@ cat <<EOF >"$TARGET/Contents/Info.plist"
 <plist version="1.0">
 <dict>
     <key>CFBundleExecutable</key>
-    <string>run.sh</string>
+    <string>${BASENAME}</string>
     <key>CFBundleIconFile</key>
     <string></string>
     <key>CFBundleInfoDictionaryVersion</key>
@@ -86,5 +87,5 @@ cat <<EOF >"$TARGET/Contents/Info.plist"
 </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