Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

Add shortcut command bm

aapanel.comee19859e4e85
diff --git a/.gitignore b/.gitignore
index 9d48d13a..bb2dec30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ config/*
data/*
temp/
ssl/*
+bm
.env
billionmail.conf
DBPASS_file.pl
diff --git a/install.sh b/install.sh
index 41500d91..a8ad06f1 100644
--- a/install.sh
+++ b/install.sh
@@ -1334,6 +1334,12 @@ EOF
sleep 5
Init_Billionmail
+ [ ! -d "/opt" ] && mkdir /opt
+ echo "${PWD_d}" > /opt/PWD-Billion-Mail.txt
+ ln -sf ${PWD_d}/mail_users.sh /usr/bin/bm
+ ln -sf ${PWD_d}/mail_users.sh ${PWD_d}/bm
+ chmod +x ${PWD_d}/mail_users.sh
+
}
@@ -1389,4 +1395,4 @@ echo -e ""
echo -e "Billion Mail address: \e[1;33mhttps://${IPV4_ADDRESS}/${SafePath}\e[0m"
echo -e "Billion Mail Username: \e[1;33m${ADMIN_USERNAME}\e[0m Password: \e[1;33m${ADMIN_PASSWORD}\e[0m"
echo -e ""
-echo -e "Tip: Use \e[33mbash mail_users.sh\e[0m to Add, Delete Domain and Mailboxes etc."
+echo -e "Tip: Use \e[33m bm \e[0m or \e[33mbash mail_users.sh\e[0m to Add Domain and login info etc."
diff --git a/mail_users.sh b/mail_users.sh
index 704721ab..7a0cf4bf 100644
--- a/mail_users.sh
+++ b/mail_users.sh
@@ -17,9 +17,22 @@ if [ $(whoami) != "root" ];then
exit 1
fi
+PWD_d=`pwd`
+# Check if the path contains "Billion-Mail"
+if [[ "${PWD_d}" != *"Billion-Mail"* ]]; then
+ if [ -f "/opt/PWD-Billion-Mail.txt" ]; then
+ DIR=$(cat /opt/PWD-Billion-Mail.txt)
+ if [ -d "${DIR}" ]; then
+ cd "${DIR}"
+ echo "Enter the Billion-Mail project directory: ${DIR}"
+ fi
+ fi
+fi
+
+
if [ ! -s ".env" ]; then
ls -al
- echo " The .env file does not exist. Cannot continue operation, please operate in the project directory"
+ echo " The .env file does not exist. Cannot continue operation, please operate in the Billion-Mail project directory"
exit 1
fi
. .env
@@ -353,9 +366,87 @@ Del_Email() {
fi
}
+
+Default_info() {
+
+ ipv4_address=""
+ ipv6_address=""
+ if [ "$address" = "" ];then
+
+ ipv4_address=$(curl -4 -sS --connect-timeout 10 -m 15 https://ifconfig.me 2>&1)
+ if [ -z "${ipv4_address}" ];then
+ ipv4_address=$(curl -4 -sS --connect-timeout 10 -m 15 https://www.aapanel.com/api/common/getClientIP 2>&1)
+ if [ -z "${ipv4_address}" ];then
+ ipv4_address=$(curl -4 -sS --connect-timeout 10 -m 15 https://www.bt.cn/Api/getIpAddress 2>&1)
+ fi
+ fi
+ IPV4_REGEX="^([0-9]{1,3}\.){3}[0-9]{1,3}$"
+ if ! [[ $ipv4_address =~ $IPV4_REGEX ]]; then
+ ipv4_address=""
+ fi
+
+ ipv6_address=$(curl -6 -sS --connect-timeout 10 -m 15 https://ifconfig.me 2>&1)
+ IPV6_REGEX="^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$"
+ if ! [[ $ipv6_address =~ $IPV6_REGEX ]]; then
+ ipv6_address=""
+ else
+ if [[ ! $ipv6_address =~ ^\[ ]]; then
+ ipv6_address="[$ipv6_address]"
+ fi
+ fi
+
+ if [ "$address" = "" ] && [ "$ipv4_address" = "" ] && [ "$ipv6_address" = "" ];then
+ address="SERVER_IP"
+ echo -e "\033[33mFailed to obtain Internet IP, please use the server Internet IP+PORT to access.\033[0m"
+ fi
+ fi
+
+ LOCAL_IP=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
+ echo -e "=================================================================="
+ echo -e "\033[32mBillion Mail default info!\033[0m"
+ echo -e "=================================================================="
+ pool=https
+ if [ "${ipv6_address}" ];then
+ if [ "${HTTPS_PORT}" = "443" ];then
+ echo "Billion Mail Internet IPv6 Address: ${pool}://${ipv6_address}/${SafePath}"
+ else
+ echo "Billion Mail Internet IPv6 Address: ${pool}://${ipv6_address}:${HTTPS_PORT}/${SafePath}"
+ fi
+ fi
+ if [ "${ipv4_address}" ];then
+ if [ "${HTTPS_PORT}" = "443" ];then
+ echo "Billion Mail Internet IPv4 Address: ${pool}://${ipv4_address}/${SafePath}"
+ else
+ echo "Billion Mail Internet IPv4 Address: ${pool}://${ipv4_address}:${HTTPS_PORT}/${SafePath}"
+ fi
+ fi
+ if [ "${address}" ];then
+ if [ "${HTTPS_PORT}" = "443" ];then
+ echo "Billion Mail Internet Address: ${pool}://${address}/${SafePath}"
+ else
+ echo "Billion Mail Internet Address: ${pool}://${address}:${HTTPS_PORT}/${SafePath}"
+ fi
+
+ fi
+
+ if [ "${HTTPS_PORT}" = "443" ];then
+ echo "Billion Mail Internal Address: ${pool}://${LOCAL_IP}/${SafePath}"
+ else
+ echo "Billion Mail Internal Address: ${pool}://${LOCAL_IP}:${HTTPS_PORT}${SafePath}"
+ fi
+
+ echo -e "Username: ${ADMIN_USERNAME} \nPassword: ${ADMIN_PASSWORD}"
+ echo -e "\033[33mWarning:\033[0m"
+ echo -e "\033[33mIf you cannot access the Billion Mail, \033[0m"
+ echo -e "\033[33mrelease the following port ${SMTP_PORT}|${SMTPS_PORT}|${SUBMISSION_PORT}|${POP_PORT}|${IMAP_PORT}|${IMAPS_PORT}|${POPS_PORT}|${HTTP_PORT}|${HTTPS_PORT} in the security group\033[0m"
+ echo -e "=================================================================="
+}
+
+
case "$1" in
h | -h | help | --help | -help)
echo "Help Information:"
+ echo " default - Show Billion Mail login default info: $0 default"
echo " add-domain <domain> - Add domain. Example: $0 add-domain example.com"
echo " del-domain <domain> - Delete domain. Example: $0 del-domain example.com"
echo " add-email <email> - Add email. Example: $0 add-email [email protected]"
@@ -364,6 +455,9 @@ case "$1" in
echo " show-email - Show email data."
echo " show-record - Show domain DNS record."
;;
+ default | info)
+ Default_info
+ ;;
add-domain)
Init_Domain "$@"
Add_Domain
@@ -389,9 +483,9 @@ case "$1" in
show-record|show_dns_record)
Init_Domain "$@"
Domain_record
- ;;
+ ;;
*)
- echo "Usage: $0 {add-domain|del-domain|add-email|del-email|show-domain|show-email|show-record|help}"
+ echo "Usage: $0 {default|add-domain|del-domain|add-email|del-email|show-domain|show-email|show-record|help}"
exit 1
;;
esac
\ No newline at end of file
diff --git a/update.sh b/update.sh
index 5e72a1b2..66ad7aed 100644
--- a/update.sh
+++ b/update.sh
@@ -9,6 +9,8 @@ POSTFIX_CONTAINER_NAME="${CONTAINER_PROJECT_NAME}-postfix-billionmail-1"
RSPAMD_CONTAINER_NAME="${CONTAINER_PROJECT_NAME}-rspamd-billionmail-1"
TIME=$(date +%Y_%m_%d_%H_%M_%S)
+PWD_d=`pwd`
+
if [ $(whoami) != "root" ];then
echo -e "Non-root install, please try the following solutions: \n 1.Please switch to root user install \n 2.Try executing the following install commands: \n sudo bash $0 $@"
exit 1
@@ -273,6 +275,12 @@ Update_BillionMail(){
echo -e "\033[33m⚠️ Update completed, please check container status. If startup failed, check container logs.\033[0m"
fi
+ [ ! -d "/opt" ] && mkdir /opt
+ echo "${PWD_d}" > /opt/PWD-Billion-Mail.txt
+ ln -sf ${PWD_d}/mail_users.sh /usr/bin/bm
+ ln -sf ${PWD_d}/mail_users.sh ${PWD_d}/bm
+ chmod +x ${PWD_d}/mail_users.sh
+
}
echo "