-
Notifications
You must be signed in to change notification settings - Fork 3
/
install-server.sh
executable file
·105 lines (88 loc) · 2.99 KB
/
install-server.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
#!/bin/bash
#
# This script sets up a cloud server with Ubuntu 16.04 or Debian 8.
# Installs and sets up all required packages for nextcloud.
# Finally installs nextcloud.
#
# Copyright (C) 2017-2019 Rainer Emrich, <[email protected]>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file LICENSE. If not see
# <http://www.gnu.org/licenses/>.
#
export START_DIR="$(pwd)"
export MYSELF="$(readlink -f "$0")"
export MYSELF_QUOTED="$(echo "${MYSELF}" | sed 's/\//\\\//g' -)"
export BASE_DIR="$(dirname "${MYSELF}")"
export ARCHIVES_DIR="${BASE_DIR}/archives"
export BM_DIR="${BASE_DIR}/backupmanager"
export CONFIG_DIR="${BASE_DIR}/config"
export DATA_DIR="${BASE_DIR}/data"
export PKG_DIR="${BASE_DIR}/packages"
export PATCH_DIR="${BASE_DIR}/patches"
export SCRIPT_DIR="${BASE_DIR}/scripts"
export STAMP_DIR="${BASE_DIR}/stamps"
if [ ! -d ${STAMP_DIR} ] ; then mkdir -p ${STAMP_DIR}; fi
. ${SCRIPT_DIR}/setup.functions.sh
get_os_release
test_os_release
get_config
show_info
ask_to_continue
if [[ "${CURRENT_FQDN}" != "localhost.localdomain" && "${CURRENT_FQDN}" != "${MY_FQDN}" ]] ; then
echo
echo "#######################################################################################"
echo "#"
echo "# ERROR: A hostname is already set and differs from the one in the configuration."
echo "# See ${CONFIG_DIR}/hostname.sh"
echo "#"
echo "# Wrong host exiting..."
echo "#"
echo "#######################################################################################"
exit
else
if [ "$(grep "\.bash_aliases" ~/.bashrc)" == "" ] ; then
case ${DIST_ID} in
Debian)
case ${DIST_RELEASE} in
8.* | \
9.*)
/bin/cp ${DATA_DIR}/root/.bashrc.debian8 ~/.bashrc
;;
*)
echo "if [ -f ~/.bash_aliases ]; then" >>~/.bashrc
echo " . ~/.bash_aliases" >>~/.bashrc
echo "fi" >>~/.bashrc
;;
esac
;;
*)
echo "if [ -f ~/.bash_aliases ]; then" >>~/.bashrc
echo " . ~/.bash_aliases" >>~/.bashrc
echo "fi" >>~/.bashrc
;;
esac
fi
test -z "$(grep "${MYSELF}" ~/.bashrc)" && echo "${MYSELF}" >>~/.bashrc
setup_hostname_network_ssh
setup_backupmanager
setup_software
test ! -z "$(grep "${MYSELF}" ~/.bashrc)" && sed --in-place "/${MYSELF_QUOTED}/d" ~/.bashrc
echo
echo "#######################################################################################"
echo "#"
echo "# INFO: Script finished!"
echo "#"
echo "#######################################################################################"
echo
fi