3 # appify -- convert your non-interactive shell script into a Mac OS X application
4 # Copyright (C) 2010 Adam Backstrom
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 echo "Usage: $0 [-h] script.sh target.app"
46 BASENAME=`basename "$SCRIPT"`
48 if [ -e "$TARGET" ]; then
49 echo "$TARGET exists, exiting" 1>&2
53 SCRIPTSIZE=$(ls -l "$SCRIPT" | awk '{print $5}')
55 if [ $SCRIPTSIZE -lt 28 ]; then
56 echo -e "Script smaller than size allowed by OS. Please pad to 28 characters." 1>&2
61 # done checking args; create the app
64 mkdir -p "$TARGET/Contents/MacOS"
65 mkdir -p "$TARGET/Contents/Resources"
69 cat <<EOF >"$TARGET/Contents/Info.plist"
70 <?xml version="1.0" encoding="UTF-8"?>
71 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
74 <key>CFBundleExecutable</key>
75 <string>${BASENAME}</string>
76 <key>CFBundleIconFile</key>
78 <key>CFBundleInfoDictionaryVersion</key>
80 <key>CFBundlePackageType</key>
82 <key>CFBundleSignature</key>
84 <key>CFBundleVersion</key>
90 cp "$SCRIPT" "$TARGET/Contents/MacOS/$BASENAME"
91 chmod 755 "$TARGET/Contents/MacOS/$BASENAME"