summaryrefslogtreecommitdiff
path: root/japanese/FreeWnn-server/pkg-install
blob: de185b3c6dcc33b8a7451cdb110d5caf951791bd (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
#!/bin/sh
# an installation script for Wnn4.2

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/master.passwd ##
    # check
    id_69=`id -u 69 2> /dev/null`
    id_wnn=`id -u wnn 2> /dev/null`
    if [ X"$id_wnn" != X ];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 Wnn4.2 in this port or package, ID number of 'wnn' has to be 69.
Please try again after you delete the account.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EOF
	exit 1
    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 Wnn || exit
    else
	echo "Please create it, and try again."
	exit 1
    fi
    ;;

POST-INSTALL)

    case $1 in
      ja-Wnn-4.2)
	sys_dirs="${PKG_PREFIX}/lib/wnn/ja_JP/dic/pubdic ${PKG_PREFIX}/lib/wnn/ja_JP/dic/wnncons"
	usr_dirs=${PKG_PREFIX}/lib/wnn/ja_JP/dic/usr
	wnntouch=${PKG_PREFIX}/bin/Wnn4/wnntouch
	wnnserver=${PKG_PREFIX}/bin/Wnn4/jserver
	wnnname=Wnn
	;;
      cn-Wnn-4.2)
	sys_dirs="${PKG_PREFIX}/lib/wnn/zh_CN/dic/sys ${PKG_PREFIX}/lib/wnn/zh_TW/dic/sys"
	usr_dirs="${PKG_PREFIX}/lib/wnn/zh_CN/dic/usr ${PKG_PREFIX}/lib/wnn/zh_TW/dic/usr"
	wnntouch=${PKG_PREFIX}/bin/cWnn4/cwnntouch
	wnnserver=${PKG_PREFIX}/bin/cWnn4/cserver
	wnnname=cWnn
	;;
      kr-Wnn-4.2)
	sys_dirs="${PKG_PREFIX}/lib/wnn/ko_KR/dic/sys"
	usr_dirs=${PKG_PREFIX}/lib/wnn/ko_KR/dic/usr
	wnntouch=${PKG_PREFIX}/bin/kWnn4/kwnntouch
	wnnserver=${PKG_PREFIX}/bin/kWnn4/kserver
	wnnname=kWnn
	;;
    esac

    for dir in $sys_dirs; do
      $wnntouch $dir/*
    done
    for dir in $usr_dirs; do
      if [ ! -d $dir ]; then
	mkdir -p $dir
      fi
      chown wnn $dir
    done

    ## create a startup script ##
    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 'if [ -f $wnn ]; then' >> ${startup_script};
      echo "    echo -n ' ${wnnname}'" >> ${startup_script};
      echo '    $wnn' >> ${startup_script};
      echo "fi" >> ${startup_script};
      chmod 755 ${startup_script};
      chown bin.bin ${startup_script};
    fi
    ;;
esac