-
Notifications
You must be signed in to change notification settings - Fork 1
/
moonoo.sh
128 lines (114 loc) · 4.65 KB
/
moonoo.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
#!/usr/bin/env bash
#===============================================================================================================================================
# (C) Copyright 2023 MooNoo a project under Hacked LLC.)
#
# Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#===============================================================================================================================================
# title :MooNoo.sh
# description :This script will make it super easy to setup mailcow, and have it be deployed in minutes.
# author :HACKED LLC.
# contributors :beard
# date :02-09-2023
# version :0.0.16 Alpha
# os :Debian/Ubuntu
# usage :bash moonoo.sh
# notes :If you have any problems feel free to email the maintainer: projects [AT] hacked [DOT] is
#===============================================================================================================================================
# Force check for root
if ! [ "$(id -u)" = 0 ]; then
echo "You need to be logged in as root!"
exit 1
fi
# Project URL, Local Directory, Dockerized Directory Repo List Path for Mapping in script.
P_URL="https://github.com/mailcow/mailcow-dockerized"
P_LOCAL_DIR="/opt/"
P_DOCKERIZED_DIR="mailcow-dockerized"
# Color for tput
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
magenta=$(tput setaf 5)
cyan=$(tput setaf 6)
white=$(tput setaf 7)
#Functions for tput
reset=$(tput sgr0)
blink=$(tput blink)
bold=$(tput bold)
reverse=$(tput rev)
underline=$(tput smul)
# Keeps the system updated
function upkeep() {
echo """${cyan}""""${bold}""Performing upkeep of system..""${reset}"""
apt-get update -y
apt-get full-upgrade -y
apt-get dist-upgrade -y
apt-get clean -y
}
# Setting up helpers for moonoo to work in sections.
function moo_install_setup() {
apt-get purge exim* postfix* docker* docker-compose*
apt-get autoremove
}
function moo_install_docker() {
curl -sSL https://get.docker.com/ | CHANNEL=stable sh
systemctl enable docker.service
systemctl start docker.service
apt install docker-compose-plugin -y
}
function moo_install_docker_compose() {
LATEST=$(curl -Ls -w %{url_effective} -o /dev/null https://github.com/docker/compose/releases/latest) && LATEST=${LATEST##*/} && curl -L https://github.com/docker/compose/releases/download/$LATEST/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
}
function moo_install_check() {
umask
cd "$P_LOCAL_DIR"
git clone "$P_URL"
cd "$P_DOCKERIZED_DIR"
}
# Checks for required pieces of software and installs those that are missing.
tools=( git apt-utils lsb-release curl dialog socat dirmngr apt-transport-https ca-certificates )
grab_eware=""
for e in "${tools[@]}"; do
if command -v "$e" > /dev/null 2>&1; then
echo """${green}""""${bold}""Dependency $e is installed..""${reset}"""
else
echo """${red}""""${bold}""Dependency $e is not installed..""${reset}"""
upkeep
grab_eware="$grab_eware $e"
fi
done
apt-get install $grab_eware
# Grabbing info on active system
flavor=$(lsb_release -cs)
system=$(lsb_release -i | grep "Distributor ID:" | sed 's/Distributor ID://g' | sed 's/["]//g' | awk '{print tolower($1)}')
# START
read -r -p """${cyan}""""${bold}""Do you want to setup Mailcow now? (Y/Yes | N/No) ""${reset}""" REPLY
case "${REPLY,,}" in
[yY]|[yY][eE][sS])
moo_install_setup
moo_install_docker
moo_install_docker_compose
moo_install_check
bash ./generate_config.sh
docker-compose pull
docker-compose up -d
;;
[nN]|[nN][oO])
echo """${red}""""${bold}""You have said no? We cannot work without your permission!""${reset}"""
;;
*)
echo """${yellow}""""${bold}""Invalid response. You okay?""${reset}"""
;;
esac