blob: 37da1a76b54baf4d436ed3335635b5193ed022a3 (
plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#!/bin/sh -e
TIZEN_SDK_INSTALL_PATH="`echo $INSTALLED_PATH`"
OLD_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax`
SYSCTL_FILE=sysctl.conf
COCOASUDO_PATH=$TIZEN_SDK_INSTALL_PATH/tools/emulator/bin
TIZEN_BIN_PATH=$TIZEN_SDK_INSTALL_PATH/platforms/tizen-3.0/common/emulator/bin
TIZEN_PLATFORM_ETC_PATH=$TIZEN_SDK_INSTALL_PATH/platforms/tizen-3.0/common/emulator/etc
TIZEN_TOOL_ETC_PATH=$TIZEN_SDK_INSTALL_PATH/tools/emulator/etc
TMP_FILE=emulator-install.sh
NEW_SHMMAXSIZE=83886080
if [ -z "$TIZEN_SDK_INSTALL_PATH" ]
then
echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log
# exit 2;
fi
function remove_tmp_file {
if [ -e "$TMP_FILE" ]
then
echo "delete $TMP_FILE"
rm -f "$TMP_FILE"
fi
}
function generate_tap_kext_cmd {
echo "cp -pR \"${TIZEN_PLATFORM_ETC_PATH}/emulator-ifup.sh\" /etc/" >> "$TMP_FILE"
echo "mkdir -p /Library/Extensions" >> "$TMP_FILE"
echo "cp -pR \"${TIZEN_TOOL_ETC_PATH}/tap.kext\" /Library/Extensions" >> "$TMP_FILE"
echo "rm -rf \"${TIZEN_TOOL_ETC_PATH}/tap.kext\"" >> "$TMP_FILE"
echo "chown -R root:wheel /Library/Extensions/tap.kext" >> "$TMP_FILE"
echo "mkdir -p /Library/LaunchDaemons" >> "$TMP_FILE"
echo "cp /Library/Extensions/tap.kext/Contents/net.sf.tuntaposx.tap.plist /Library/LaunchDaemons" >> "$TMP_FILE"
echo "kextutil -nt /Library/Extensions/tap.kext" >> "$TMP_FILE"
echo "/sbin/kextload /Library/Extensions/tap.kext" >> "$TMP_FILE"
}
function generate_sudoer_cmd {
cat << 'EOF' >> $TMP_FILE
FILE=/etc/sudoers
BACKFILE=/etc/sudoers.bak
TMPFILE=/etc/sudoers.tmp
MESSAGE="# Tizen SDK generated the following script. Do not modify."
LINE1="User_Alias QEMUERS="
LINE2="Cmnd_Alias QEMU=/etc/emulator-ifup.sh, /etc/emulator-ifdown.sh"
LINE3="QEMUERS ALL=(ALL) NOPASSWD: QEMU"
count=0
if [[ "$USER" == "" ]]
then
echo "user is not set. aborting..."
exit 1
fi
while read line
do
echo $line
count=$((count+1))
if [[ $line == $LINE1* ]]
then
echo "find original script"
NAMES=`echo $line | cut -d = -f2`
if [[ "$NAMES"x == ""x ]]
then
cp $FILE $BACKFILE
# in case of blank user
eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE
exit 0
fi
for i in $(echo $NAMES | tr "," "\n")
do
if [[ "$i" == "$USER" ]]
then
echo "already added the same user"
exit 0
fi
done
cp $FILE $BACKFILE
# new user is added with comma behind the original users.
eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE
mv $TMPFILE $FILE
exit 0
fi
done < $FILE
cp $FILE $BACKFILE
echo "do not find qemu sudoer. add it"
echo "$MESSAGE" >> $FILE
echo "$LINE1$USER" >> $FILE
echo "$LINE2" >> $FILE
echo "$LINE3" >> $FILE
exit 0
EOF
}
function prepare {
TAP_ZIP_FILE="$TIZEN_TOOL_ETC_PATH/tap.zip"
TAP_KEXT="$TIZEN_TOOL_ETC_PATH/tap.kext"
USER=`id -un`
echo "create $TMP_FILE"
echo "#!/bin/sh" > "$TMP_FILE"
echo "TIZEN_SDK_INSTALL_PATH=$TIZEN_SDK_INSTALL_PATH" >> "$TMP_FILE"
echo "USER=$USER" >> "$TMP_FILE"
}
function generate {
generate_tap_kext_cmd;
generate_sudoer_cmd;
}
function execute {
/bin/chmod +x "$TMP_FILE"
"$COCOASUDO_PATH/cocoasudo" --prompt="Please enter your password to install Tizen Emulator." sh -x "$TMP_FILE"
}
function cleanup {
remove_tmp_file;
}
prepare;
generate;
execute;
cleanup;
CURRENT_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax`
if [ ! $OLD_SHMMAXSIZE -eq $CURRENT_SHMMAXSIZE ]
then
echo 'need reboot'
exit 99
fi
|