Lines 1-143
Link Here
|
1 |
#!/bin/sh |
|
|
2 |
# |
3 |
# tdiary-FreeBSD.sh - tDiary user directory copy script |
4 |
# |
5 |
# $FreeBSD: ports/www/tdiary/files/tdiary-FreeBSD.sh.in,v 1.4 2003/11/09 12:59:57 jeh Exp $ |
6 |
# |
7 |
# usage: |
8 |
# % /usr/local/share/examples/tdiary/tdiary-FreeBSD.sh install |
9 |
# or |
10 |
# # /usr/local/share/examples/tdiary/tdiary-FreeBSD.sh USERid |
11 |
# |
12 |
|
13 |
USERNAME=$1 |
14 |
DIARYDIR=diary |
15 |
PUBLICHTML=public_html |
16 |
PREFIX=@@@@PREFIX@@@@ |
17 |
TDCONFIG=@@@@LANG@@@@ |
18 |
EXAMPLES=${PREFIX}/share/examples |
19 |
HOMEOWN=`grep ^$1: /etc/passwd | cut -f3 -d':'` |
20 |
HOMEGRP=`grep ^$1: /etc/passwd | cut -f4 -d':'` |
21 |
AUTHORN=`grep ^$1: /etc/passwd | cut -f5 -d':'` |
22 |
HOMEDIR=`grep ^$1: /etc/passwd | cut -f6 -d':'` |
23 |
HOSTSMTP=`hostname` |
24 |
|
25 |
cd ${EXAMPLES} |
26 |
|
27 |
if [ -z "$1" ]; then |
28 |
echo "Usage: `basename $0` {username} or install" |
29 |
exit 1 |
30 |
else |
31 |
if [ -z "${HOMEOWN}" ] ; then |
32 |
if [ "$1" = "install" ] ; then |
33 |
if [ $(id -u) -eq 0 ]; then |
34 |
echo "root can not use 'install' parameter." |
35 |
exit 1 |
36 |
fi |
37 |
else |
38 |
echo "User unknown or no exist User Directory -> " $1 "-" ${HOMEDIR} |
39 |
echo "Usage: `basename $0` {username} or install" |
40 |
exit 1 |
41 |
fi |
42 |
fi |
43 |
fi |
44 |
|
45 |
echo "************************************************************" |
46 |
echo "" |
47 |
|
48 |
case "$1" in |
49 |
root) |
50 |
echo "You can not copy ROOT Directory" |
51 |
exit 1 |
52 |
;; |
53 |
install) |
54 |
HOMEOWN=`grep ^$USER: /etc/passwd | cut -f3 -d':'` |
55 |
HOMEGRP=`grep ^$USER: /etc/passwd | cut -f4 -d':'` |
56 |
HOMEDIR=`grep ^$USER: /etc/passwd | cut -f6 -d':'` |
57 |
echo "HOME Directory : " ${HOMEDIR} |
58 |
USERNAME=$USER |
59 |
;; |
60 |
*) |
61 |
echo "HOME Directory : " ${HOMEDIR} |
62 |
echo "USERNAME : " ${USERNAME} |
63 |
USERNAME=$USER |
64 |
;; |
65 |
esac |
66 |
|
67 |
if [ -x ${HOMEDIR} ]; then |
68 |
if [ -z "$1" ]; then |
69 |
echo "Usage: `basename $0` {username} or install" |
70 |
exit 1 |
71 |
else |
72 |
echo "" |
73 |
echo "************************************************************" |
74 |
echo "Starting tDiary for FreeBSD user directory installation ..." |
75 |
echo "" |
76 |
if [ ! -e ${HOMEDIR}/${DIARYDIR} ]; then |
77 |
echo "Create ..." ${HOMEDIR}/${DIARYDIR} |
78 |
mkdir ${HOMEDIR}/${DIARYDIR} |
79 |
echo "Done" |
80 |
fi |
81 |
chmod o+rwx ${HOMEDIR}/${DIARYDIR} |
82 |
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${DIARYDIR} |
83 |
if [ ! -e ${HOMEDIR}/${PUBLICHTML} ]; then |
84 |
echo "Create ..." ${HOMEDIR}/${USERNAME}/${PUBLICHTML} |
85 |
mkdir ${HOMEDIR}/${PUBLICHTML} |
86 |
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML} |
87 |
echo "Done" |
88 |
fi |
89 |
echo "Copy tDiary ..." ${EXAMPLES}/tdiary/ |
90 |
echo " to " ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/ |
91 |
cp -pR ${EXAMPLES}/tdiary/ ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/ |
92 |
chown -R ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/ |
93 |
chmod o+rwx ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR} |
94 |
echo "Done" |
95 |
sed -e 's#'/home/foo/diary'#'${HOMEDIR}'/'${DIARYDIR}'#g' \ |
96 |
-e 's#smtp.example.net#'${HOSTSMTP}'#g' \ |
97 |
-e "s#foo@example.net#"${USERNAME}"@"${HOSTSMTP}"#g" \ |
98 |
-e "s#Your name#${AUTHORN}#g" \ |
99 |
-e "s#hogehoge diary#${AUTHORN} Diary#g" \ |
100 |
-e "s#http://www.example.net/~foo/#http://"${HOSTSMTP}"/~"${USERNAME}"#g" \ |
101 |
< ${EXAMPLES}/tdiary/tdiary.conf.sample > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf-ja |
102 |
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf-ja |
103 |
if [ -e ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/.htaccess ]; then |
104 |
sed -e 's#foo#'${USERNAME}'#g' < ${EXAMPLES}/tdiary/dot.htaccess > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/dot.htaccess.orig |
105 |
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/dot.htaccess.orig |
106 |
else |
107 |
sed -e 's#foo#'${USERNAME}'#g' < ${EXAMPLES}/tdiary/dot.htaccess > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/.htaccess |
108 |
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/.htaccess |
109 |
fi |
110 |
sed -e 's#'/home/foo/diary'#'${HOMEDIR}'/'${DIARYDIR}'#g' \ |
111 |
-e 's#smtp.example.net#'${HOSTSMTP}'#g' \ |
112 |
-e "s#foo@example.net#"${USERNAME}"@"${HOSTSMTP}"#g" \ |
113 |
-e "s#Your name#${AUTHORN}#g" \ |
114 |
-e "s#foobar diary#${AUTHORN} Diary#g" \ |
115 |
-e "s#Foo\'s diary#${AUTHORN}\'s Diary#g" \ |
116 |
-e "s#http://www.example.net/~foo/#http://"${HOSTSMTP}"/~"${USERNAME}"#g" \ |
117 |
< ${EXAMPLES}/tdiary/misc/i18n/tdiary.conf.sample-en > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf-en |
118 |
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf-en |
119 |
rm -f ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary-FreeBSD.sh |
120 |
if [ -e ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf ]; then |
121 |
echo "" |
122 |
else |
123 |
echo "Install ${TDCONFIG} ... Done" |
124 |
mv ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/${TDCONFIG} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf |
125 |
fi |
126 |
fi |
127 |
else |
128 |
echo "" |
129 |
echo "User unknown or no exist User Directory -> " $1 "-" ${HOMEDIR} |
130 |
echo "Usage: `basename $0` {username} or install" |
131 |
exit 1 |
132 |
fi |
133 |
echo "" |
134 |
echo "" |
135 |
echo "***" |
136 |
echo "You have to execute the following commands:" |
137 |
echo " % /usr/local/sbin/htpasswd -c" ${HOMEDIR}/.htpasswd ${USERNAME} |
138 |
echo "" |
139 |
echo "Be sure to read the ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/README" |
140 |
echo " file for additional information." |
141 |
echo "************************************************************" |
142 |
echo "" |
143 |
exit 0 |