This repository has been archived by the owner on Dec 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_bbs_ubuntu.sh
executable file
·134 lines (114 loc) · 3.18 KB
/
setup_bbs_ubuntu.sh
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
#!/bin/bash
echo "
--------------------------------------------------------
warning:
* make sure you have changed the password in this script
* current, the script is designed for Ubuntu Server only
* backup and double check before anything
script will start after 10 second, press CTRL-C to abort
--------------------------------------------------------"
sleep 10
# configuration
DIR=`cd $(dirname $0); pwd`
GITSRC="git://github.com/guessi/easttownbbs.git"
BBSUID="9999"
BBSGID="9999"
USER="bbs"
GROUP="bbs"
BBSHOME="/home/bbs"
USRSHELL="/bin/bash"
PASSWORD="changeme"
ENCRYPTED=`openssl passwd -1 ${PASSWORD}`
echo "setup source.list... "
if [ "$(lsb_release -cs)" = "precise" ]; then
sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
fi
# package setup
echo "apt-get update... "
apt-get update
echo "security upgrade..."
apt-get upgrade -y
echo "Preparing for basic packages... "
apt-get install -qqy curl wget vim tree htop
echo "Preparing for the required packages... "
apt-get install -qqy git wget build-essential csh gcc libc6 libc6-dev make
echo -n "Generating group \"bbs\"... "
grep -q "^${GROUP}" /etc/group
if [ $? -eq 0 ]; then
echo "Skip, already exist"
else
groupadd -g ${BBSGID} ${GROUP}
echo "Done"
fi
echo -n "Checking group \"bbs\" GID... "
TMP=`grep "${USER}" /etc/group | cut -d":" -f3`
if [ ${TMP} != ${BBSGID} ]; then
echo ${TMP}
echo -n "Changing group \"bbs\" GID... "
groupmod -g ${BBSGID} ${GROUP}
echo "Done"
else
echo "Pass"
fi
echo -n "Checking user \"bbs\" existence... "
id ${USER} >/dev/null
if [ $? -eq 0 ]; then
echo "Found"
else
echo "Not found"
echo -n "Creating user \"bbs\"... "
useradd -m -u ${BBSUID} -g ${GROUP} -s ${USRSHELL} -p ${ENCRYPTED} ${USER}
echo "Done"
fi
echo -n "Checking for source folder's existance... "
if [ -d ${DIR}/easttownbbs ]; then
mv -f ${DIR}/easttownbbs ${DIR}/easttownbbs-old
fi
echo "Done"
mkdir -p ${BBSHOME}
git clone ${GITSRC}
cp -rf ./easttownbbs/bbs/* ${BBSHOME}
cp -rvf ./easttownbbs/bbs/.BRD ${BBSHOME}
sed -i '/^#define BBSGID/s/[ \t]\+99/\t\t9999/' ${BBSHOME}/src/include/config.h
chown -R bbs:bbs ${BBSHOME}
echo -n "Setting up for rc.local... "
grep -q "bbsd" /etc/rc.local
if [ $? -eq 0 ]; then
echo "Skip, already exist"
else
HOMEBIN="\/home\/bbs\/bin"
HOMEINN="\/home\/bbs\/innd"
sed -i "s/^exit 0$/\
${HOMEBIN}\/bbsd\n\
${HOMEBIN}\/bmtad\n\
${HOMEBIN}\/gemd\n\
${HOMEBIN}\/bguard\n\
${HOMEBIN}\/bhttpd\n\
${HOMEBIN}\/bpop3d\n\
${HOMEBIN}\/bnntpd\n\
${HOMEBIN}\/xchatd\n\
${HOMEINN}\/innbbsd\n\n\
su bbs -c \'${HOMEBIN}\/camera\'\n\
su bbs -c \'${HOMEBIN}\/account\'\n\n\
exit 0/g" /etc/rc.local
echo "Done"
fi
echo -n "Checking for xchat/bbsnntp services existance... "
egrep -q '(xchat|bbsnntp)' /etc/services
if [ $? -eq 0 ]; then
echo "Skip, already exist"
else
sed -i '/^telnet[ \t]\+23\/tcp$/a\
xchat\t\t3838\/tcp\
xchat\t\t3838\/udp\
bbsnntp\t\t7777\/tcp\tusenet\
bbsnntp\t\t7777\/udp\tusenet' /etc/services
echo "Done"
fi
su bbs -c 'cd /home/bbs/src; make clean linux install update'
result=$?
if [ $result -eq 0 ]; then
echo "now you may reboot your system and check if everything works fine"
else
echo "oops... something error"
fi