blob: 915b13031851f5c1e9e46a67defe1452ec979f2c (
plain) (
blame)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
#!/bin/sh
# an installation script for Wnn6
check_pw()
{
if which -s pw; then
:
else
cat <<EOF
This system looks like a pre-2.2 version of FreeBSD. We see that it
is missing the "pw" utility. We need this utility. Please get and
install it, and try again. You can get the source from:
ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.sbin/pw.tar.gz
EOF
exit 1
fi
}
ask() {
local question default answer
question=$1
default=$2
if [ -z "${PACKAGE_BUILDING}" ]; then
read -p "${question} (y/n) [${default}]? " answer
fi
if [ x${answer} = x ]; then
answer=${default}
fi
echo ${answer}
}
yesno() {
local dflt question answer
question=$1
dflt=$2
while :; do
answer=$(ask "${question}" "${dflt}")
case "${answer}" in
[Yy]*) return 0;;
[Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
case $2 in
PRE-INSTALL)
## Hack /etc/services ##
FILE="/etc/services"
# check
OK=no
HAS_WNN6=no
COUNT=1
for i in `grep wnn6 $FILE `; do
if [ $COUNT = 1 ] && [ X"$i" = X"wnn6" ]; then
HAS_WNN6=yes
elif [ $COUNT = 2 ] && [ $HAS_WNN6 = yes ] && \
[ X"$i" = X"22273/tcp" ]; then
OK=yes
break
fi
COUNT=`expr ${COUNT} + 1`
done
# add an entry for wnn6 to /etc/services
if [ $OK = no ]; then
echo "This system has no entry for Wnn6 in ${FILE}"
if yesno "Would you like to add it automatically?" y; then
mv ${FILE} ${FILE}.bak
(grep -v wnn6 ${FILE}.bak ; \
echo "wnn6 22273/tcp # Wnn6") >> ${FILE}
rm ${FILE}.bak
else
echo "Please add 'wnn6 22273/tcp' into ${FILE}, and try again."
exit 1
fi
fi
## Hack /etc/master.passwd ##
# check
id_69=`id -u 69 2> /dev/null`
id_wnn=`id -u wnn 2> /dev/null`
if [ X"$id_wnn" = X69 ];then
exit 0
elif [ X"$id_69" != X ]; then
cat <<EOF
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This system already has an account whose name is not 'wnn' and ID
number is 69.
'`id 69`'
For Wnn6 in this port or package, ID number of 'wnn' has to be 69.
Please try again after you delete the account.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EOF
exit 1
elif [ X"$id_wnn" != X ]; then
cat <<EOF
This system has an 'wnn' account whose ID number is $id_wnn. It seems
that Wnn4.2 has been already installed. For Wnn6 in this ports or
package, ID number of 'wnn' has to be 69. So we do the following two
things:
1) You should delete the account.
2) It seems that all of files or directories for Wnn4.2 are in
${PKG_PREFIX}/lib/wnn and ${PKG_PREFIX}/bin. You should change these ID
number from '$id_wnn' to '69'.
Notice: After doing 1) and 2), we will create a new 'wnn' account
whose ID number is '69'.
EOF
if yesno "Would you like to do the above things automatically" y; then
# We need a command 'pw(8)'
check_pw
pw userdel wnn
if [ $? != 0 ]; then
echo ""
echo "Cannot delete it. Please do it, and try again."
exit 1
fi
find ${PKG_PREFIX}/lib/wnn ${PKG_PREFIX}/bin \
-user $id_wnn -exec chown 69 {} \;
else
echo "Please do those, and try again."
exit 1
fi
fi
# add an account 'wnn' to this system
echo ""
echo "You need an account 'wnn' whose ID number is 69"
if yesno "Would you like to create it automatically?" y; then
# We need a command 'pw(8)'
check_pw
pw useradd wnn -u 69 -g 7 -h - -d /nonexistent \
-s /nonexistent -c Wnn6 || exit
else
echo "Please create it, and try again."
exit 1
fi
;;
POST-INSTALL)
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cd /usr/local/bin; rm -f Wnn6; ln -s ${PKG_PREFIX}/OMRONWnn6/Wnn6fbsd Wnn6
cd /usr/local/lib; rm -f wnn6; ln -s ${PKG_PREFIX}/OMRONWnn6/wnn6fbsd wnn6
if [ X${PKG_PREFIX} != X"/usr/local" ]; then
echo
echo "Warning!!"
echo "We made symbolic links from \"/usr/local/bin/Wnn6\" to \"${PKG_PREFIX}/OMRONWnn6/Wnn6fbsd\""
echo "and from \"/usr/local/lib/wnn6\" to \"${PKG_PREFIX}/OMRONWnn6/wnn6fbsd\""
fi
cd ${PKG_PREFIX}/OMRONWnn6/wnn6fbsd/ja_JP; rm -f dic; ln -s ../../wnn6dic dic
chown -R wnn ${PKG_PREFIX}/OMRONWnn6
## create a startup script ##
wnnserver=/usr/local/bin/Wnn6/jserver
wnnname=Wnn6
startup_script=${PKG_PREFIX}/etc/rc.d/${wnnname}.sh
if [ ! -f ${startup_script} ]; then
echo "Installing ${startup_script} startup file."
echo '#!/bin/sh' > ${startup_script};
echo "wnn=${wnnserver}" >> ${startup_script};
echo 'case $1 in' >> ${startup_script};
echo 'start)' >> ${startup_script};
echo ' if [ -f $wnn ]; then' >> ${startup_script};
echo " echo -n ' ${wnnname}'" >> ${startup_script};
echo ' $wnn' >> ${startup_script};
echo " fi" >> ${startup_script};
echo ' ;;' >> ${startup_script};
echo 'stop)' >> ${startup_script};
echo ' killall $wnn' >> ${startup_script};
echo " echo -n ' ${wnnname}'" >> ${startup_script};
echo ' ;;' >> ${startup_script};
echo '*)' >> ${startup_script};
echo ' echo "Usage: `basename $0` {start|stop}" >&2' >> ${startup_script};
echo ' ;;' >> ${startup_script};
echo 'esac' >> ${startup_script};
echo 'exit 0' >> ${startup_script};
chmod 755 ${startup_script}
chown bin.bin ${startup_script}
fi
;;
esac
|