-
Notifications
You must be signed in to change notification settings - Fork 3
/
On Demand scripting tips.rtf
75 lines (63 loc) · 1.77 KB
/
On Demand scripting tips.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{\rtf1\ansi\ansicpg1252\cocoartf2512
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica-Bold;\f1\fswiss\fcharset0 Helvetica;\f2\fmodern\fcharset0 Courier;
\f3\fswiss\fcharset0 ArialMT;\f4\fswiss\fcharset0 Arial-BoldMT;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww12280\viewh13480\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\f0\b\fs28 \cf0 Munki SelfService (On Demand) Script Tips
\f1\b0\fs24 \
\
\fs28 This is just a reminder of what Greg has written on the munki dev forum.\
\
\f0\b 1) Byline (also called \'93the Shebang\'94)
\f1\b0 \
Start the script with a byline on its own line:\
\pard\pardeftab720\partightenfactor0
\f2 \cf0 \expnd0\expndtw0\kerning0
#!/bin/bash
\f3 \
or \
\f2 #!/bin/sh
\f3 \
\
\f4\b 2) References
\f3\b0 \
When the script is run from inside the plist you have to be quite literal.\
\
Tools need to be referenced in full\
\f2 /usr/bin/osascript
\f3 instead of
\f2 osascript\
/bin/rm
\f3 instead of
\f2 rm
\f3 \
\
File references can\'92t start with
\f2 ~/
\f3 for the Home directory
\f2 \
\f3 You need the full path:
\f2 /Users/username/Library/Preferences/..
\f3 \
You can tease out the actual active user account name with:\
\
\f2 #Get User Name\
userName=$(stat -f "%Su" /dev/console)\
\f3 \
And then pop it into the reference as a variable like this:\
\f2 /Users/$userName/Library/Preferences/..
\f3 \
\
\f4\b 3) Characters
\f3\b0 \
If the script is coming from a plist then you want to prevent the XML parser from misinterpreting certain characters. \
\'93>\'94, \'93<\'93 and \'93&\'94 are all used in XML so you need to spec them in HTML\
> for >\
< for <\
& for &\
\
\'97\
Alex Narvey\
precursor.ca}