Compare commits

..

4 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
5d371293e0 Restore informative messages about manual Docker daemon configuration
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-10 08:32:50 +00:00
copilot-swe-agent[bot]
215a8addff Add clarifying comment about MAILCOW_CONF usage in configure_ipv6
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-10 08:24:45 +00:00
copilot-swe-agent[bot]
8f58ba8bc8 Fix generate_config.sh termination when user declines IPv6 Docker configuration
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-10 08:22:23 +00:00
copilot-swe-agent[bot]
70affa0f69 Initial plan 2025-12-10 08:18:16 +00:00
2 changed files with 87 additions and 84 deletions

View File

@@ -139,9 +139,13 @@ docker_daemon_edit(){
exit 1 exit 1
fi fi
else else
echo -e "${YELLOW}User declined Docker update please insert these changes manually:${NC}" echo -e "${YELLOW}User declined Docker update skipping Docker daemon configuration.${NC}"
echo -e "${YELLOW}IPv6 will be disabled for mailcow.${NC}"
echo ""
echo -e "${YELLOW}If you change your mind later, please insert these changes manually to $DOCKER_DAEMON_CONFIG:${NC}"
echo "${MISSING[*]}" echo "${MISSING[*]}"
exit 1 echo ""
return 1
fi fi
fi fi
@@ -185,9 +189,23 @@ EOF
(command -v systemctl &>/dev/null && systemctl restart docker) || service docker restart (command -v systemctl &>/dev/null && systemctl restart docker) || service docker restart
echo "Docker restarted." echo "Docker restarted."
else else
echo "User declined to create daemon.json please manually merge the docker daemon with these configs:" echo -e "${YELLOW}User declined to create daemon.json skipping Docker daemon configuration.${NC}"
echo "${MISSING[*]}" echo -e "${YELLOW}IPv6 will be disabled for mailcow.${NC}"
exit 1 echo ""
echo -e "${YELLOW}If you change your mind later, please create $DOCKER_DAEMON_CONFIG with these settings:${NC}"
if [[ -n "$DOCKER_MAJOR" && "$DOCKER_MAJOR" -lt 27 ]]; then
echo ' "ipv6": true,'
echo ' "fixed-cidr-v6": "fd00:dead:beef:c0::/80",'
echo ' "ip6tables": true,'
echo ' "experimental": true'
elif [[ -n "$DOCKER_MAJOR" && "$DOCKER_MAJOR" -lt 28 ]]; then
echo ' "ipv6": true,'
echo ' "fixed-cidr-v6": "fd00:dead:beef:c0::/80"'
else
echo ' "ipv6": true'
fi
echo ""
return 1
fi fi
fi fi
} }
@@ -223,7 +241,22 @@ configure_ipv6() {
return return
fi fi
docker_daemon_edit if ! docker_daemon_edit; then
# User declined Docker daemon configuration
# When called from update.sh, MAILCOW_CONF is set and we modify the existing file
# When called from generate_config.sh, MAILCOW_CONF is not set and we export IPV6_BOOL
if [[ -n "$MAILCOW_CONF" && -f "$MAILCOW_CONF" ]]; then
if grep -q '^ENABLE_IPV6=' "$MAILCOW_CONF"; then
sed -i 's/^ENABLE_IPV6=.*/ENABLE_IPV6=false/' "$MAILCOW_CONF"
else
echo "ENABLE_IPV6=false" >> "$MAILCOW_CONF"
fi
else
export IPV6_BOOL=false
fi
echo "IPv6 configuration complete: ENABLE_IPV6=false"
return 0
fi
if [[ -n "$MAILCOW_CONF" && -f "$MAILCOW_CONF" ]]; then if [[ -n "$MAILCOW_CONF" && -f "$MAILCOW_CONF" ]]; then
if grep -q '^ENABLE_IPV6=' "$MAILCOW_CONF"; then if grep -q '^ENABLE_IPV6=' "$MAILCOW_CONF"; then

View File

@@ -842,11 +842,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
); );
continue; continue;
} }
if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) { if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
'type' => 'danger', 'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => 'access_denied' 'msg' => 'access_denied'
); );
continue; continue;
} }
@@ -2732,11 +2732,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$gal = (isset($_data['gal'])) ? intval($_data['gal']) : $is_now['gal']; $gal = (isset($_data['gal'])) ? intval($_data['gal']) : $is_now['gal'];
$description = (!empty($_data['description']) && isset($_SESSION['acl']['domain_desc']) && $_SESSION['acl']['domain_desc'] == "1") ? $_data['description'] : $is_now['description']; $description = (!empty($_data['description']) && isset($_SESSION['acl']['domain_desc']) && $_SESSION['acl']['domain_desc'] == "1") ? $_data['description'] : $is_now['description'];
(int)$relayhost = (isset($_data['relayhost']) && isset($_SESSION['acl']['domain_relayhost']) && $_SESSION['acl']['domain_relayhost'] == "1") ? intval($_data['relayhost']) : intval($is_now['relayhost']); (int)$relayhost = (isset($_data['relayhost']) && isset($_SESSION['acl']['domain_relayhost']) && $_SESSION['acl']['domain_relayhost'] == "1") ? intval($_data['relayhost']) : intval($is_now['relayhost']);
$tags_raw = isset($_data['tags']) ? $_data['tags'] : array(); $tags = (is_array($_data['tags']) ? $_data['tags'] : array());
$tags = is_array($tags_raw) ? $tags_raw : json_decode($tags_raw, true);
if (!is_array($tags)) {
$tags = array();
}
} }
else { else {
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
@@ -2757,11 +2753,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
':domain' => $domain ':domain' => $domain
)); ));
// save tags // save tags
foreach($tags as $index => $tag){ foreach($tags as $index => $tag){
if (empty($tag)) continue; if (empty($tag)) continue;
if ($index > $GLOBALS['TAGGING_LIMIT']) { if ($index > $GLOBALS['TAGGING_LIMIT']) {
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
'type' => 'warning', 'type' => 'warning',
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => array('tag_limit_exceeded', 'limit '.$GLOBALS['TAGGING_LIMIT']) 'msg' => array('tag_limit_exceeded', 'limit '.$GLOBALS['TAGGING_LIMIT'])
); );
@@ -2773,8 +2769,6 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
':tag_name' => $tag, ':tag_name' => $tag,
)); ));
} }
$stmt = $pdo->prepare("UPDATE `domain` SET `modified` = NOW() WHERE `domain` = :domain");
$stmt->execute(array(':domain' => $domain));
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
'type' => 'success', 'type' => 'success',
@@ -2797,11 +2791,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$maxquota = (!empty($_data['maxquota'])) ? $_data['maxquota'] : ($is_now['max_quota_for_mbox'] / 1048576); $maxquota = (!empty($_data['maxquota'])) ? $_data['maxquota'] : ($is_now['max_quota_for_mbox'] / 1048576);
$quota = (!empty($_data['quota'])) ? $_data['quota'] : ($is_now['max_quota_for_domain'] / 1048576); $quota = (!empty($_data['quota'])) ? $_data['quota'] : ($is_now['max_quota_for_domain'] / 1048576);
$description = (!empty($_data['description'])) ? $_data['description'] : $is_now['description']; $description = (!empty($_data['description'])) ? $_data['description'] : $is_now['description'];
$tags_raw = isset($_data['tags']) ? $_data['tags'] : array(); $tags = (is_array($_data['tags']) ? $_data['tags'] : array());
$tags = is_array($tags_raw) ? $tags_raw : json_decode($tags_raw, true);
if (!is_array($tags)) {
$tags = array();
}
if ($relay_all_recipients == '1') { if ($relay_all_recipients == '1') {
$backupmx = '1'; $backupmx = '1';
} }
@@ -2941,19 +2931,17 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
); );
break; break;
} }
$stmt = $pdo->prepare("INSERT INTO `tags_domain` (`domain`, `tag_name`) VALUES (:domain, :tag_name)"); $stmt = $pdo->prepare("INSERT INTO `tags_domain` (`domain`, `tag_name`) VALUES (:domain, :tag_name)");
$stmt->execute(array( $stmt->execute(array(
':domain' => $domain, ':domain' => $domain,
':tag_name' => $tag, ':tag_name' => $tag,
)); ));
} }
$stmt = $pdo->prepare("UPDATE `domain` SET `modified` = NOW() WHERE `domain` = :domain");
$stmt->execute(array(':domain' => $domain)); $_SESSION['return'][] = array(
'type' => 'success',
$_SESSION['return'][] = array( 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'type' => 'success', 'msg' => array('domain_modified', htmlspecialchars($domain))
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => array('domain_modified', htmlspecialchars($domain))
); );
} }
} }
@@ -6120,15 +6108,14 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
else { else {
$domains = $_data['domain']; $domains = $_data['domain'];
} }
$tags_raw = isset($_data['tags']) ? $_data['tags'] : array(); $tags = $_data['tags'];
$tags = is_array($tags_raw) ? $tags_raw : json_decode($tags_raw, true);
if (!is_array($tags)) $tags = array(); if (!is_array($tags)) $tags = array();
$modifiedDomains = array();
$wasModified = false; $wasModified = false;
foreach ($domains as $domain) { foreach ($domains as $domain) {
if (!is_valid_domain_name($domain)) { if (!is_valid_domain_name($domain)) {
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
'type' => 'danger', 'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => 'domain_invalid' 'msg' => 'domain_invalid'
@@ -6141,44 +6128,27 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => 'access_denied' 'msg' => 'access_denied'
); );
return false; return false;
} }
$domainModified = false; foreach($tags as $tag){
foreach($tags as $tag){ // delete tag
// delete tag $wasModified = true;
$domainModified = true; $stmt = $pdo->prepare("DELETE FROM `tags_domain` WHERE `domain` = :domain AND `tag_name` = :tag_name");
$wasModified = true; $stmt->execute(array(
$stmt = $pdo->prepare("DELETE FROM `tags_domain` WHERE `domain` = :domain AND `tag_name` = :tag_name"); ':domain' => $domain,
$stmt->execute(array( ':tag_name' => $tag,
':domain' => $domain, ));
':tag_name' => $tag, }
)); }
}
if ($domainModified) { if (!$wasModified) return false;
$modifiedDomains[] = $domain; $_SESSION['return'][] = array(
} 'type' => 'success',
} 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => array('domain_modified', $domain)
if (!$wasModified) return false; );
if (!empty($modifiedDomains)) { break;
$placeholders = array();
$params = array();
foreach ($modifiedDomains as $idx => $modifiedDomain) {
$placeholders[] = ":domain".$idx;
$params[":domain".$idx] = $modifiedDomain;
}
$stmt = $pdo->prepare("UPDATE `domain` SET `modified` = NOW() WHERE `domain` IN (".implode(',', $placeholders).")");
$stmt->execute($params);
$modifiedDomains = array_map('htmlspecialchars', $modifiedDomains);
}
$modifiedDomains = (empty($modifiedDomains)) ? array('-') : $modifiedDomains;
$_SESSION['return'][] = array(
'type' => 'success',
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => array('domain_modified', implode(', ', $modifiedDomains))
);
break;
case 'tags_mailbox': case 'tags_mailbox':
if (!is_array($_data['username'])) { if (!is_array($_data['username'])) {
$usernames = array(); $usernames = array();