In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to understand the script installed under iredmail". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand the script installed under iredmail".
Iredmail is a set of installation scripts for integrating mail systems with postfix as the core, which can achieve the purpose of rapid deployment of mail servers.
After a series of analysis above, we go to the step of getting the installation package, where the author writes a separate script, get_all.sh, and we continue to analyze this script
_ ROOTDIR= "$(pwd)"
CONF_DIR= "${_ ROOTDIR} /.. / conf"
. ${CONF_DIR} / global
. ${CONF_DIR} / core
. ${CONF_DIR} / iredadmin
The program means to use pwd to get the current directory and define it as _ ROOTDIR, and then get the exact location of the CONF directory according to _ ROOTDIR. Thus introducing global, core ireadmin
A series of variables about version and iredadmin are defined in the iredadmin file, which may be used later when downloading the file, as shown in the figure
Continue with the analysis.
Check_user root
Check_hostname
Check_runtime_dir
In my experience, it is obvious that check_user check_hostname check_runtime_dir is a function of SHELL. Let's analyze them one by one.
Check_user is defined in the conf/core file. The specific code is as follows:
Check_user () {# Check special user privilege to execute this script. If [X "$(id-u)"! = X "$(id-u ${1})"]; then ECHO_ERROR "Please run this script as user: ${1}." Exit 255else if [X "$(id-u)" = = X "0"]; then export PATH= "/ usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" else: fi fi}
Id-u obviously gets the ID of the logged-in user. When calling the function, check_user root obviously determines whether it is root based on the returned result, and returns an error if it is not root.
Exit 255regarding this, please refer to this article, https://www.yisu.com/article/73377.htm
I don't know whether the judgment after else is a bit redundant, but the author may decide again whether the login user's ID is 0 for insurance, thus setting the value of PATH.
PATH: determines in which directories shell will look for commands or programs. The value of PATH is a series of directories under which Linux searches for compiled links when you run a program.
Currently set this value, much more than normal / root/bin/, do not know whether this step plays any role in the later program, can not be seen for the time being.
Then... no, no, no.
Check_hostname is used to analyze whether the server host name conforms to the rules. The code is as follows:
Check_hostname () {echo ${HOSTNAME} | grep'\.'& > / dev/null [X "$?"! = X "0"] & &\ ECHO_ERROR "Please configure a fully qualified domain name (FQDN) in / etc/hosts before we go further.\ n\ nExample:\ n\ n127.0.0.1 mail.iredmail.org mail localhost\ n" & &\ exit 255}
The program means to use ${HOSTNAME} to get the hostname if it is not in the hostname. It is judged that the host name is unreasonable, then an example is given, and then exit the program.
The functions of shell are relatively simple, and then analyze check_runtime_dir. The code is as follows:
Check_runtime_dir () {[- d ${RUNTIME_DIR}] | | mkdir-p ${RUNTIME_DIR} # Cleanup rm-f ${RUNTIME_DIR} / .pkg _ install_failed & > / dev/null}
-d to determine whether the directory exists
Mkdir-p create a directory
It should be judged here that there are files that failed to clean up in the directory, and there is no establishment directory.
After the execution of three functions to check whether the user, hostname, and status directory exist, the installation conditions are appropriate, and the following code defines the address to download the installation package:
Export IREDMAIL_MIRROR= "${IREDMAIL_MIRROR:= http://iredmail.org}"
Export PKG_DIR= "${_ ROOTDIR} / pkgs"
Export PKG_MISC_DIR= "${_ ROOTDIR} / misc"
Http://iredmail.org this is the author's official home page and the address where the installation package is downloaded. Because the script supports several mainstream LINUX, the following code is used to analyze and judge multiple systems. Look at the code.
If [X "${DISTRO}" = X "RHEL"]; then # Special package. # command: which. Export BIN_WHICH='which' export PKG_WHICH='which' # command: wget. Export BIN_WGET='wget' export PKG_WGET='wget'elif [X "${DISTRO}" = X "DEBIAN"-o X "${DISTRO}" = X "UBUNTU"]; then if [X "${OS_ARCH}" = X "x86x64"]; then export pkg_arch='amd64' else export pkg_arch= "${OS_ARCH}" fi # Special package. # command: which. Export BIN_WHICH='which' export PKG_WHICH= "debianutils" # command: wget. Export BIN_WGET='wget' export PKG_WGET= "wget" # command: dpkg-scanpackages. Export BIN_CREATEREPO= "dpkg-scanpackages" export PKG_CREATEREPO= "dpkg-dev" fi thank you for reading, this is the content of "how to understand the script installed under iredmail". After the study of this article, I believe you have a deeper understanding of how to understand the script installed under iredmail, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.