ยง2024-10-02
- Complete Mail Server by Scripts, install.sh
#! /bin/bash
# execute this script ./install.sh yushei.net mail.yushei.net
# where yushei.net is the domain name and mail.yushei.net is the hostname
# make sure the install script is started here
OURNAME=install.sh
INSTALLDIR=`pwd`
# A Simple Public IP Address API, https://www.ipify.org/
# this will get your public IP, where this script is executing
# e.g. mail.yushei.net --> 59.126.118.194
PUBLIC_IP=`curl -s https://api.ipify.org`
# source will execute the file
source "$INSTALLDIR/00_install_global_functions_variables.sh"
args=("$@")
# "$@": This refers to all the positional arguments passed to the script or function,
# echo $# arguments passed
# echo ${args[0]} ${args[1]} ${args[2]}
if [ "$#" -gt "0" ]
then
# foo/bar -> bar
MAILDOMAIN=${args[0]}
HOSTNAME=${args[1]:-$MAILDOMAIN}
echo -e "DOMAINNAME: ${GREEN}$MAILDOMAIN${NC}, HOSTNAME: ${GREEN}$HOSTNAME${NC}"
else
echo -e "we got ${RED}ZERO${NC} arguments, so here is the manual:"
fun_print_help
exit
fi
if [[ $EUID -ne 0 ]]; then
# redirect stdout(1) to stderr(2)
# (&2, & means it is a filedescriptor and not a file named "2")
echo -e "${RED}ERROR:${NC}This script must be run as root" 1>&2
echo -e "Execute ${GREEN}sudo bash${NC} , ${ORANGE}sudo su${NC} or ${ORANGE}sudo sh${NC}"
exit 1
fi
# source is for executing in the current shell, and not in a subset.
# defined variables persists across files
declare -a arr=(
"01_install_commits.sh"
"02_install_prerequisites.sh"
"03_install_check_running_services.sh"
"04_install_import_keys.sh"
"05_install_packages.sh"
"06_install_enable_services.sh"
"07_install_wildduck.sh"
"08_install_haraka.sh"
"09_install_zone_mta.sh"
"10_install_wildduck_webmail.sh"
"11_install_nginx.sh"
"12_install_ufw_rules.sh"
"13_install_ssl_certs.sh"
"14_install_start_services.sh"
"15_install_deploy.sh"
)
for i in "${arr[@]}"
do
source "$INSTALLDIR/$i"
done
<html>
<head>
<meta name="viewport" content="width=device-width">
<title>https://api.ipify.org/</title>
<link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css">
</head>
<body id="viewsource" class="highlight" style="tab-size: 4">
<pre>210.242.152.235</pre>
</body>
</html>
- href="resource://content-accessible/viewsource.css">
@charset "utf-8";
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
*|*:root {
color-scheme: light dark;
direction: ltr;
-moz-control-character-visibility: visible;
height: 100%;
}
#viewsource {
font-family: -moz-fixed;
font-weight: normal;
white-space: pre;
counter-reset: line;
height: 100%;
box-sizing: border-box;
margin: 0;
padding: 8px;
}
#viewsource.wrap {
white-space: pre-wrap;
word-wrap: break-word;
}
pre {
font: inherit;
color: inherit;
white-space: inherit;
margin: 0 0 0 5ch;
}
pre[id]:before,
span[id]:before {
content: counter(line) " ";
counter-increment: line;
user-select: none;
display: inline-block;
width: 5ch;
margin: 0 0 0 -5ch;
text-align: right;
color: #ccc;
font-weight: normal;
font-style: normal;
}
.highlight .start-tag,
.highlight .end-tag {
color: purple;
font-weight: bold;
}
.highlight .comment {
color: green;
font-style: italic;
}
.highlight .cdata {
color: #CC0066;
}
.highlight .doctype,
.highlight .markupdeclaration {
color: steelblue;
font-style: italic;
}
.highlight .pi {
color: orchid;
font-style: italic;
}
.highlight .entity {
color: #FF4500;
font-weight: normal;
}
.highlight .text {
font-weight: normal;
}
.highlight .attribute-name {
font-weight: bold;
}
.highlight .attribute-value {
color: blue;
font-weight: normal;
}
span:not(.error),
a:not(.error) {
unicode-bidi: embed;
}
span[id] {
unicode-bidi: isolate;
}
.highlight .error {
color: revert;
font-weight: bold;
background-color: rgba(231, 116, 113, 0.3);
text-decoration: underline wavy red 0.5px;
}
@media (prefers-color-scheme: dark) {
.highlight .start-tag,
.highlight .end-tag {
color: #f55e5e;
}
.highlight .comment {
color: lightgreen;
}
.highlight .cdata {
color: #f068ac;
}
.highlight .doctype,
.highlight .markupdeclaration {
color: lightgray;
}
.highlight .entity {
color: #f18a65;
}
.highlight .attribute-value {
color: #97bbff;
}
}
explain why curl -s https://api.ipify.org
will return the ip of where this command is excuted?