blob: 7b936942b22cc8f63016f75d510154b20d60d50e (
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
|
#!/bin/sh
#
# tdiary-FreeBSD.sh - tDiary user directory copy script
#
# $FreeBSD$
#
# usage:
# % /usr/local/share/examples/tdiary/tdiary-FreeBSD.sh install
# or
# # /usr/local/share/examples/tdiary/tdiary-FreeBSD.sh USERid
#
USERNAME=$1
DIARYDIR=diary
PUBLICHTML=public_html
PREFIX=@@@@PREFIX@@@@
EXAMPLES=${PREFIX}/share/examples
HOMEOWN=`grep ^$1: /etc/passwd | cut -f3 -d':'`
HOMEGRP=`grep ^$1: /etc/passwd | cut -f4 -d':'`
HOMEDIR=`grep ^$1: /etc/passwd | cut -f6 -d':'`
HOSTSMTP=`hostname`
cd ${EXAMPLES}
if [ -z "$1" ]; then
echo "Usage: `basename $0` {username} or install"
exit 1
else
if [ -z "${HOMEOWN}" ] ; then
if [ "$1" = "install" ] ; then
if [ $(id -u) -eq 0 ]; then
echo "root can not use 'install' parameter."
exit 1
fi
else
echo "User unknown or no exist User Directory -> " $1 "-" ${HOMEDIR}
echo "Usage: `basename $0` {username} or install"
exit 1
fi
fi
fi
echo "************************************************************"
echo ""
case "$1" in
root)
echo "You can not copy ROOT Directory"
exit 1
;;
install)
HOMEOWN=`grep ^$USER: /etc/passwd | cut -f3 -d':'`
HOMEGRP=`grep ^$USER: /etc/passwd | cut -f4 -d':'`
HOMEDIR=`grep ^$USER: /etc/passwd | cut -f6 -d':'`
# HOMEOWN=$USER
# HOMEGRP=$GROUP
# HOMEDIR=$HOME
echo "HOME Directory : " ${HOMEDIR}
USERNAME=$USER
;;
*)
echo "HOME Directory : " ${HOMEDIR}
echo "USERNAME : " ${USERNAME}
USERNAME=$USER
;;
esac
if [ -x ${HOMEDIR} ]; then
if [ -z "$1" ]; then
echo "Usage: `basename $0` {username} or install"
exit 1
else
echo ""
echo "************************************************************"
echo "Starting tDiary for FreeBSD user directory installation ..."
echo ""
if [ ! -e ${HOMEDIR}/${DIARYDIR} ]; then
echo "Create ..." ${HOMEDIR}/${DIARYDIR}
mkdir ${HOMEDIR}/${DIARYDIR}
echo "Done"
fi
chmod o+rwx ${HOMEDIR}/${DIARYDIR}
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${DIARYDIR}
if [ ! -e ${HOMEDIR}/${PUBLICHTML} ]; then
echo "Create ..." ${HOMEDIR}/${USERNAME}/${PUBLICHTML}
mkdir ${HOMEDIR}/${PUBLICHTML}
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}
echo "Done"
fi
echo "Copy tDiary ..." ${EXAMPLES}/tdiary/
echo " to " ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/
cp -pR ${EXAMPLES}/tdiary/ ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/
chown -R ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/
chmod o+rwx ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}
echo "Done"
if [ -e ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf ]; then
sed -e 's#'/home/foo/diary'#'${HOMEDIR}'/'${DIARYDIR}'#g' \
-e 's#smtp.example.net#'${HOSTSMTP}'#g' \
-e "s#foo@example.net#"${USERNAME}"@"${HOSTSMTP}"#g" \
-e "s#http://www.example.net/~foo/#http://"${HOSTSMTP}"/~"${USERNAME}"#g" \
< ${EXAMPLES}/tdiary/tdiary.conf.sample > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf.orig
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf.orig
else
sed -e 's#'/home/foo/diary'#'${HOMEDIR}'/'${DIARYDIR}'#g' \
-e 's#smtp.example.net#'${HOSTSMTP}'#g' \
-e "s#foo@example.net#"${USERNAME}"@"${HOSTSMTP}"#g" \
-e "s#http://www.example.net/~foo/#http://"${HOSTSMTP}"/~"${USERNAME}"#g" \
< ${EXAMPLES}/tdiary/tdiary.conf.sample > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf
fi
if [ -e ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/.htaccess ]; then
sed -e 's#foo#'${USERNAME}'#g' < ${EXAMPLES}/tdiary/dot.htaccess > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/dot.htaccess.orig
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/dot.htaccess.orig
else
sed -e 's#foo#'${USERNAME}'#g' < ${EXAMPLES}/tdiary/dot.htaccess > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/.htaccess
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/.htaccess
fi
sed -e 's#'/home/foo/diary'#'${HOMEDIR}'/'${DIARYDIR}'#g' \
-e 's#smtp.example.net#'${HOSTSMTP}'#g' \
-e "s#foo@example.net#"${USERNAME}"@"${HOSTSMTP}"#g" \
-e "s#http://www.example.net/~foo/#http://"${HOSTSMTP}"/~"${USERNAME}"#g" \
< ${EXAMPLES}/tdiary/misc/i18n/tdiary.conf.sample-en > ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf-en
chown ${HOMEOWN}:${HOMEGRP} ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary.conf-en
rm -f ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/tdiary-FreeBSD.sh
fi
else
echo ""
echo "User unknown or no exist User Directory -> " $1 "-" ${HOMEDIR}
echo "Usage: `basename $0` {username} or install"
exit 1
fi
echo ""
echo ""
echo "***"
echo "You have to execute the following commands:"
echo " % /usr/local/sbin/htpasswd -c" ${HOMEDIR}/.htpasswd ${USERNAME}
echo ""
echo "Be sure to read the ${HOMEDIR}/${PUBLICHTML}/${DIARYDIR}/README"
echo " file for additional information."
echo "************************************************************"
echo ""
exit 0
|