install.sh

Giacomo Sanchietti, 01/27/2014 03:42 PM

Download (2.75 KB)

 
1
#
2
# Copyright © 2014 Nethesis S.r.l.
3
# http://www.nethesis.it - support@nethesis.it
4
# 
5
# This script is part of NethServer.
6
# 
7
# NethServer is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License,
10
# or any later version.
11
# 
12
# NethServer is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
# 
17
# You should have received a copy of the GNU General Public License
18
# along with NethServer.  If not, see <http://www.gnu.org/licenses/>.
19
#
20
#
21
#
22
# This script will install NethServer.
23
# Default installation will include only base system.
24
# If you need to install more modules, you can specifies them on the command line.
25
#
26
# Default installtion:
27
# 
28
#     nethserver-install
29
#
30
# Install mail server
31
#
32
#     nethserver-install mail-server
33
#
34
#
35

    
36
function log {
37
    echo `date` "$1" >> /var/log/nethserver-install.log
38
}
39

    
40
function logexec {
41
    cmd=$1
42
    log "$cmd"
43
    $cmd | tee -a /var/log/nethserver-install.log
44
}
45

    
46
function end {
47
    echo
48
    echo "You can access the Web interface at:"
49
    hostname=`/sbin/e-smith/db configuration get SystemName`
50
    domainname=`/sbin/e-smith/db configuration get DomainName`
51
    echo
52
    echo -n "    https://$hostname.$domainname:980"
53
    for k in `/sbin/e-smith/db networks keys`
54
    do
55
       role=`/sbin/e-smith/db networks getprop $k role`
56
       if [ "$role" == "green" ]; then
57
           ip=$(/sbin/e-smith/db networks getprop eth0 ipaddr)
58
           echo " (or https://$ip:980)"
59
       fi
60
    done
61
    echo 
62
    echo "    Login: root" 
63
    echo "    Password: <your_root_password>"
64
    echo
65
    echo
66
    echo "Installation log can be found here: /var/log/nethserver-install.log"
67
    echo
68
    echo
69
    log "End"
70
    exit 0
71
}
72

    
73
rpm -q nethserver-base >/dev/null
74
if [ $? -eq 0 ]; then
75
   echo
76
   echo "NethServer is already installed!"
77
   log "Already installed"
78
   end
79
fi
80

    
81
modules=""
82
if [ $# -gt 0 ]; then
83
   echo "The following extra modules will also be installed: $@"
84
   log "Extra modules: $@"
85
   for m in $@
86
   do
87
       modules="$modules @$m"
88
   done
89
fi
90

    
91

    
92
log "Starting installation"
93
echo "Starting installation process. It will take a while..."
94
echo
95
echo "Installing base system..."
96
echo
97
logexec "rpm --import /etc/pki/rpm-gpg/*"
98
logexec "yum --disablerepo=* --enablerepo=nethserver-base,nethserver-updates,centos-base,centos-updates --releasever=6.4 install @nethserver-iso -y"
99
logexec "/sbin/e-smith/signal-event system-init"
100
if [ "$modules" != "" ]; then
101
    echo 
102
    echo "Installing extra modules..."
103
    echo
104
    logexec "yum install $modules -y"
105
fi
106
end