-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
68 lines (57 loc) · 1.34 KB
/
config.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
#!/bin/bash
check_linux(){
echo -n "Checking OS : "
if [ `uname` != 'Linux' ]; then
echo 'This script could be execute under Linux Environment.'
exit 1
fi
echo "Running with `uname`"
}
check_bash(){
echo -n "Checking Shell : "
if [ `readlink /proc/$$/exe` = '/bin/bash' ]; then
echo 'Running with bash.'
return 0
fi
echo 'This script reqires running with bash.'
exit 2
}
check_root(){
echo -n "Checking User : "
if [ ${EUID:-${UID}} -ne 0 ]; then
echo 'This script requires root privilege.'
exit 3
fi
echo "This script running as root."
}
check_exist_file(){
fname=$1
if [ -e $fname ];then
echo "${fname} is exist."
return 0
fi
echo "${fname} is not exist."
exit 4
}
set -e
cd `dirname $0`
check_linux
check_bash
check_root
echo "Checking required files... : "
check_exist_file ./sysconf/generate-system-configurations.rb
check_exist_file ./sysconf/ezztp_default_config.erb
check_exist_file ./sysconf/interfaces.erb
echo "OK."
echo 'Starting Network Configuration...'
pushd sysconf
/usr/bin/env ruby ./generate-system-configurations.rb -f
popd
echo 'Configuration auto start related daemons...'
update-rc.d ezztp-ftp defaults
update-rc.d ezztp-dhcpd defaults
echo 'Starting EzZTP Initial Configuration...'
pushd /home/ezztp/ezztp
chown -R ezztp:ezztp .
sudo -u ezztp /bin/bash ./init.sh
popd