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 if [ -d "$TARGET" ]; then
26 echo "$TARGET exists, exiting" 1>&2
30 SCRIPTSIZE=$(ls -l "$SCRIPT" | awk '{print $5}')
32 if [ $SCRIPTSIZE -lt 28 ]; then
33 echo -e "Please pad your script to at least 28 bytes; Mac OS X will not\nrecognize scripts that are smaller than this value." 1>&2
37 mkdir -p "$TARGET/Contents/MacOS"
38 mkdir -p "$TARGET/Contents/Resources"
40 cat <<EOF >"$TARGET/Contents/Info.plist"
41 <?xml version="1.0" encoding="UTF-8"?>
42 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
45 <key>CFBundleExecutable</key>
46 <string>run.sh</string>
47 <key>CFBundleIconFile</key>
49 <key>CFBundleInfoDictionaryVersion</key>
51 <key>CFBundlePackageType</key>
53 <key>CFBundleSignature</key>
55 <key>CFBundleVersion</key>
61 cp "$SCRIPT" "$TARGET/Contents/MacOS/run.sh"
62 chmod 755 "$TARGET/Contents/MacOS/run.sh"