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