]> arthur.barton.de Git - appify.git/blob - appify.sh
55052f834d8c629e4f8dd166a910ab9b69eacfb0
[appify.git] / appify.sh
1 #!/bin/bash
2
3 #
4 # appify -- convert your non-interactive shell script into a Mac OS X application
5 # Copyright (C) 2010  Adam Backstrom
6
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.
11
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.
16
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.
20 #
21
22 SCRIPT=$1
23 TARGET=$2
24
25 if [ -d "$TARGET" ]; then
26     echo "$TARGET exists, exiting" 1>&2
27     exit 1
28 fi
29
30 SCRIPTSIZE=$(ls -l "$SCRIPT" | awk '{print $5}')
31
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
34     exit 2
35 fi
36
37 mkdir -p "$TARGET/Contents/MacOS"
38 mkdir -p "$TARGET/Contents/Resources"
39
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">
43 <plist version="1.0">
44 <dict>
45     <key>CFBundleExecutable</key>
46     <string>run.sh</string>
47     <key>CFBundleIconFile</key>
48     <string></string>
49     <key>CFBundleInfoDictionaryVersion</key>
50     <string>1.0</string>
51     <key>CFBundlePackageType</key>
52     <string>APPL</string>
53     <key>CFBundleSignature</key>
54     <string>????</string>
55     <key>CFBundleVersion</key>
56     <string>1.0</string>
57 </dict>
58 </plist>
59 EOF
60
61 cp "$SCRIPT" "$TARGET/Contents/MacOS/run.sh"
62 chmod 755 "$TARGET/Contents/MacOS/run.sh"