Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
domainepublic
alternc
Commits
f2ff02c5
Commit
f2ff02c5
authored
Aug 25, 2012
by
Alan Garcia
Browse files
Delete mailbox
parent
06a2eb67
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitattributes
View file @
f2ff02c5
...
...
@@ -530,6 +530,7 @@ src/functions_dns.sh -text
src/functions_hosting.sh -text
src/mail_add -text
src/mail_del -text
src/mail_deletion.sh -text
src/mem_add -text
src/mem_del -text
src/quota_delete -text
...
...
debian/alternc.cron.d
View file @
f2ff02c5
...
...
@@ -14,6 +14,9 @@
#
Every
5
minutes
,
spool
waiting
domain
changes
*/
5
*
*
*
*
root
/
usr
/
lib
/
alternc
/
update_domains
.
sh
#
Every
5
minutes
,
delete
mails
*/
5
*
*
*
*
root
/
usr
/
lib
/
alternc
/
mail_deletion
.
sh
#
Every
hour
,
check
for
slave_dns
refreshes
5
*
*
*
*
root
/
usr
/
lib
/
alternc
/
slave_dns
...
...
src/mail_deletion.sh
0 → 100755
View file @
f2ff02c5
#!/bin/bash
# This script look in the database wich mail should be DELETEd
# Source some configuration file
for
CONFIG_FILE
in
\
/etc/alternc/local.sh
\
/usr/lib/alternc/functions.sh
do
if
[
!
-r
"
$CONFIG_FILE
"
]
;
then
echo
"Can't access
$CONFIG_FILE
."
exit
1
fi
.
"
$CONFIG_FILE
"
done
#FIXME: do the lock
#FIXME: this var should be define by local.sh
ALTERNC_MAIL_LOC
=
"/var/alternc/mail"
# List the local addresses to DELETE
# Foreach => Mark for deleting and start deleting the files
# If process is interrupted, the row isn't deleted. We have to force it by reseting mail_action to 'DELETE'
mysql_query
"SELECT id, quote(replace(path,'!','
\\
!')) FROM mailbox WHERE mail_action='DELETE';"
|while
read id
path
;
do
mysql_query
"UPDATE mailbox set mail_action='DELETING' WHERE id=
$id
;"
# Check there is no instruction of changing directory, and check the first part of the string
if
[[
"
$path
"
=
~
'../'
||
"
$path
"
=
~
'/..'
||
!
"'
$ALTERNC_MAIL_LOC
"
==
"
${
path
:0:
$((${#
ALTERNC_MAIL_LOC
}
+
1
))}
"
]]
;
then
echo
"Error : this directory will not be deleted, pattern incorrect"
continue
fi
test
-d
$path
&&
nice
10
rm
-rf
$path
mysql_query
"DELETE FROM mailbox WHERE id=
$id
;"
done
# List the adresses to DELETE
# Delete if only if there isn't any mailbox refering to it
mysql_query
"DELETE FROM a using address a, mailbox m WHERE a.mail_action='DELETE' OR a.mail_action='DELETING' AND a.id != m.address_id;"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment