瀏覽代碼

Minor and temp. workaround for panel

andryyy 8 年之前
父節點
當前提交
53b6662aea
共有 3 個文件被更改,包括 59 次插入156 次删除
  1. 0 91
      data/misc/mailcow-setup-relayhost.sh
  2. 58 64
      data/web/admin.php
  3. 1 1
      data/web/inc/init_db.inc.php

+ 0 - 91
data/misc/mailcow-setup-relayhost.sh

@@ -1,91 +0,0 @@
-#!/bin/bash
-
-# Postfix smtp_tls_security_level should be set to "may" to try an
-# encrypted connection.
-
-if [ "$EUID" -ne 0 ]
-	then echo "Please run as root"
-	exit 1
-fi
-
-# Find script directory and move to base directory of mailcow-dockerized
-# so docker-compose is executed from the right location
-DIR=$(echo $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | sed 's/data\/misc.*//')
-cd $DIR
-
-if [[ ${1} == "reset" ]]; then
-	# Reset modified values to their defaults
-	sed -i "s/^relayhost\ \=.*/relayhost\ \=/" data/conf/postfix/main.cf
-	sed -i "s/^smtp\_sasl\_password\_maps.*/smtp\_sasl\_password\_maps\ \=/" data/conf/postfix/main.cf
-	sed -i "s/^smtp\_sasl\_security\_options.*/smtp\_sasl\_security\_options\ \=\ noplaintext\,\ noanonymous/" data/conf/postfix/main.cf
-	sed -i "s/^smtp\_sasl\_auth\_enable.*/smtp\_sasl\_auth\_enable\ \=\ no/" data/conf/postfix/main.cf
-	# Also delete the plaintext password file
-	rm -f data/conf/postfix/smarthost_passwd*
-	docker-compose exec postfix-mailcow postfix reload
-	# Exit last exit code
-	exit $?
-elif [[ ${1} == "restore-string" ]]; then
-	# Set parameter value of smtp_sasl_password_maps
-	SMTPSASLPWDMAP="data/conf/postfix/smarthost_passwd"
-	# Get parameter value of relayhost
-	RELAYHOSTCFG=$(grep "relayhost\ =" data/conf/postfix/main.cf | awk '{print $3}')
-	# Exit if empty/unset
-	[[ -z ${RELAYHOSTCFG} ]] && exit 0
-	# Replace ':' by ' ' (white space)
-	RELAYHOSTCFG=${RELAYHOSTCFG//\:/ }
-	# Replace '[' by '' (empty)
-	RELAYHOSTCFG=${RELAYHOSTCFG//\[/}
-	# Replace ']' by '' (empty) and create array of result
-	RELAYHOSTCFGARR=(${RELAYHOSTCFG//\]/})
-	# Get 'username:password' from SASL password maps
-	# Grep relayhost without port and '[', ']' or ':' from SASL password map file without map type (e.g. 'hash:')
-	USRPWD=$(grep ${RELAYHOSTCFGARR[0]} $SMTPSASLPWDMAP | awk {'print $2'})
-	# Replace ':' by ' ' and create array of result
-	USRPWDARR=(${USRPWD//:/ })
-	# Echo script name, all values in RELAYHOSTCFGARR, first and second value in USRPWDARR
-	# Why?
-	# Host and port are required, so we can print the whole array RELAYHOSTCFGARR.
-	# Password might be empty, so we print them separately.
-	echo ${0} ${RELAYHOSTCFGARR[@]} \'${USRPWDARR[0]}\' \'${USRPWDARR[1]}\'
-	exit 0
-elif [[ -z ${1} ]] || [[ -z ${2} ]]; then
-	# Exit with code 1 if host and port are missing
-	echo "Usage: ${0} relayhost port (username) (password)"
-	echo "Username and password are optional parameters."
-	exit 1
-else
-	# Try a simple connection to host:port but don't recieve any data
-	# Abort after 3 seconds
-	if ! nc -z -v -w3 ${1} ${2} 2>/dev/null; then
-		echo "Connection to relayhost ${1} failed, aborting..."
-		exit 1
-	fi
-	# Use exact hostname as relayhost, don't lookup the MX record of relayhost
-	sed -i "s/relayhost\ \=.*/relayhost\ \=\ \[${1}\]\:${2}/" data/conf/postfix/main.cf
-	if grep -q "smtp_sasl_password_maps" data/conf/postfix/main.cf
-	then
-		sed -i "s/^smtp\_sasl\_password\_maps.*/smtp\_sasl\_password\_maps\ \=\ hash\:\/opt\/postfix\/conf\/smarthost\_passwd/" data/conf/postfix/main.cf
-	else
-		echo "smtp_sasl_password_maps = hash:/opt/postfix/conf/smarthost_passwd" >>  data/conf/postfix/main.cf
-	fi
-	if grep -q "smtp_sasl_auth_enable" data/conf/postfix/main.cf
-	then
-		sed -i "s/^smtp\_sasl\_auth\_enable.*/smtp\_sasl\_auth\_enable\ \=\ yes/" data/conf/postfix/main.cf
-	else
-		echo "smtp_sasl_auth_enable = yes" >>  data/conf/postfix/main.cf
-	fi
-	if grep -q "smtp_sasl_security_options" data/conf/postfix/main.cf
-	then
-		sed -i "s/^smtp\_sasl\_security\_options.*/smtp\_sasl\_security\_options\ \=/" data/conf/postfix/main.cf
-	else
-		echo "smtp_sasl_security_options =" >>  data/conf/postfix/main.cf
-	fi
-	if [[ ! -z ${3} ]]; then
-		echo ${1} ${3}:${4} > data/conf/postfix/smarthost_passwd
-		docker-compose exec postfix-mailcow postmap /opt/postfix/conf/smarthost_passwd
-	fi
-	docker-compose exec postfix-mailcow chown root:postfix /opt/postfix/conf/smarthost_passwd /opt/postfix/conf/smarthost_passwd.db
-	docker-compose exec postfix-mailcow chmod 660 /opt/postfix/conf/smarthost_passwd /opt/postfix/conf/smarthost_passwd.db
-	docker-compose exec postfix-mailcow postfix reload
-	exit $?
-fi

+ 58 - 64
data/web/admin.php

@@ -183,11 +183,11 @@ $tfa_data = get_tfa();
   </div>
   </div>
 
 
   <h4><span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> <?=$lang['admin']['configuration'];?></h4>
   <h4><span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> <?=$lang['admin']['configuration'];?></h4>
+
   <div class="panel-group" id="accordion_access">
   <div class="panel-group" id="accordion_access">
-  
+
   <div class="panel panel-default">
   <div class="panel panel-default">
   <div class="panel-heading"><?=$lang['admin']['dkim_keys'];?></div>
   <div class="panel-heading"><?=$lang['admin']['dkim_keys'];?></div>
-  <div id="collapseDKIM" class="panel-collapse">
   <div class="panel-body">
   <div class="panel-body">
     <p style="margin-bottom:40px"><?=$lang['admin']['dkim_key_hint'];?></p>
     <p style="margin-bottom:40px"><?=$lang['admin']['dkim_key_hint'];?></p>
     <?php
     <?php
@@ -299,78 +299,72 @@ $tfa_data = get_tfa();
     </form>
     </form>
   </div>
   </div>
   </div>
   </div>
-  </div>
   
   
   <div class="panel panel-default">
   <div class="panel panel-default">
-  <div style="cursor:pointer;" class="panel-heading" data-toggle="collapse" data-parent="#accordion_access" data-target="#collapseForwardingHosts">
-    <span class="accordion-toggle"><?=$lang['admin']['forwarding_hosts'];?></span>
-  </div>
-    <div id="collapseForwardingHosts" class="panel-collapse collapse">
-      <div class="panel-body">
-        <p style="margin-bottom:40px"><?=$lang['admin']['forwarding_hosts_hint'];?></p>
-        <form method="post">
-          <div class="table-responsive">
-          <table class="table table-striped" id="forwardinghoststable">
-            <thead>
-            <tr>
-              <th style="min-width: 100px;"><?=$lang['edit']['host'];?></th>
-              <th style="min-width: 100px;"><?=$lang['edit']['source'];?></th>
-              <th style="text-align: right; min-width: 200px;"><?=$lang['admin']['action'];?></th>
-            </tr>
-            </thead>
-            <tbody>
-              <?php
-              $forwarding_hosts = get_forwarding_hosts();
-              if ($forwarding_hosts) {
-                foreach ($forwarding_hosts as $host) {
-                  $source = $host->source;
-                  $host = $host->host;
-                ?>
-                <tr id="data">
-                  <td><?=htmlspecialchars(strtolower($host));?></td>
-                  <td><?=htmlspecialchars(strtolower($source));?></td>
-                  <td style="text-align: right;">
-                    <div class="btn-group">
-                      <a href="delete.php?forwardinghost=<?=$host;?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['admin']['remove'];?></a>
-                    </div>
-                  </td>
-                  </td>
-                </tr>
-
-                <?php
-                }
-              } else {
+    <div class="panel-heading"><?=$lang['admin']['forwarding_hosts'];?></div>
+    <div class="panel-body">
+      <p style="margin-bottom:40px"><?=$lang['admin']['forwarding_hosts_hint'];?></p>
+      <form method="post">
+        <div class="table-responsive">
+        <table class="table table-striped" id="forwardinghoststable">
+          <thead>
+          <tr>
+            <th style="min-width: 100px;"><?=$lang['edit']['host'];?></th>
+            <th style="min-width: 100px;"><?=$lang['edit']['source'];?></th>
+            <th style="text-align: right; min-width: 200px;"><?=$lang['admin']['action'];?></th>
+          </tr>
+          </thead>
+          <tbody>
+            <?php
+            $forwarding_hosts = get_forwarding_hosts();
+            if ($forwarding_hosts) {
+              foreach ($forwarding_hosts as $host) {
+                $source = $host->source;
+                $host = $host->host;
               ?>
               ?>
-                <tr id="no-data"><td colspan="4" style="text-align: center; font-style: italic;"><?=$lang['admin']['no_record'];?></td></tr>
+              <tr id="data">
+                <td><?=htmlspecialchars(strtolower($host));?></td>
+                <td><?=htmlspecialchars(strtolower($source));?></td>
+                <td style="text-align: right;">
+                  <div class="btn-group">
+                    <a href="delete.php?forwardinghost=<?=$host;?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['admin']['remove'];?></a>
+                  </div>
+                </td>
+                </td>
+              </tr>
+
               <?php
               <?php
               }
               }
-              ?>
-            </tbody>
-          </table>
-          </div>
-        </form>
-        <small>
-        <legend><?=$lang['admin']['add_forwarding_host'];?></legend>
-        <p style="margin-bottom:10px"><?=$lang['admin']['forwarding_hosts_add_hint'];?></p>
-        <form class="form-horizontal" role="form" method="post">
-          <div class="form-group">
-            <label class="control-label col-sm-2" for="hostname"><?=$lang['edit']['host'];?>:</label>
-            <div class="col-sm-10">
-              <input type="text" class="form-control" name="hostname" id="hostname" required>
-            </div>
+            } else {
+            ?>
+              <tr id="no-data"><td colspan="4" style="text-align: center; font-style: italic;"><?=$lang['admin']['no_record'];?></td></tr>
+            <?php
+            }
+            ?>
+          </tbody>
+        </table>
+        </div>
+      </form>
+      <legend><?=$lang['admin']['add_forwarding_host'];?></legend>
+      <p class="help-block"><?=$lang['admin']['forwarding_hosts_add_hint'];?></p>
+      <form class="form-horizontal" role="form" method="post">
+        <div class="form-group">
+          <label class="control-label col-sm-2" for="hostname"><?=$lang['edit']['host'];?>:</label>
+          <div class="col-sm-10">
+            <input type="text" class="form-control" name="hostname" id="hostname" required>
           </div>
           </div>
-          <div class="form-group">
-            <div class="col-sm-offset-2 col-sm-10">
-              <button type="submit" name="add_forwarding_host" class="btn btn-default"><?=$lang['admin']['add'];?></button>
-            </div>
+        </div>
+        <div class="form-group">
+          <div class="col-sm-offset-2 col-sm-10">
+            <button type="submit" name="add_forwarding_host" class="btn btn-default"><?=$lang['admin']['add'];?></button>
           </div>
           </div>
-        </form>
-        </small>
-      </div>
-    </div>
+        </div>
+      </form>
     </div>
     </div>
   </div>
   </div>
 
 
+  </div>
+
 </div> <!-- /container -->
 </div> <!-- /container -->
 <script type='text/javascript'>
 <script type='text/javascript'>
 <?php
 <?php

+ 1 - 1
data/web/inc/init_db.inc.php

@@ -3,7 +3,7 @@ function init_db_schema() {
   try {
   try {
     global $pdo;
     global $pdo;
 
 
-    $db_version = "20042017_1926";
+    $db_version = "23042017_1807";
 
 
     $stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); 
     $stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); 
     $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
     $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));