0,0 → 1,55 |
#!/bin/sh |
|
# |
# HostAdmiral backend. Executed with ROOT privileges |
# |
# The script moves specified old domain dir to new one |
# |
# Params: |
# old_domain (e.g. example.com) |
# new_domain (e.g. domain.net) |
# |
# Return: |
# 0 - nothing done, all OK |
# 2 - dir moved |
# 3 - wrong params |
# 4 - some error |
# 5 - error from system |
# |
|
### config ################################################ |
|
. `dirname $0`/scripts.conf |
|
### validate params ####################################### |
|
if [ -z "$2" -o -n "$3" ] ; then echo "Wrong params 1"; exit 3; fi |
|
OLD="/$1/" |
echo "$OLD" | awk '$0 ~ "//" || $0 ~ "/\\./" || $0 ~ "/\\.\\./" || $0 !~ "^/(([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)\\.)*([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)/$" {exit 1} {exit 0}' |
if [ $? -ne 0 ]; then |
echo "Wrong params 2"; exit 3 |
fi |
|
NEW="/$2/" |
echo "$NEW" | awk '$0 ~ "//" || $0 ~ "/\\./" || $0 ~ "/\\.\\./" || $0 !~ "^/(([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)\\.)*([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)/$" {exit 1} {exit 0}' |
if [ $? -ne 0 ]; then |
echo "Wrong params 3"; exit 3 |
fi |
|
### work ################################################## |
|
if [ -d "${ROOT}${NEW}" ] ; then |
# the new maildir exists already - error |
exit 4; |
else |
# the new maildir doesn't exist and the old one doesn't exist - do nothing |
if [ ! -d "${ROOT}${OLD}" ] ; then |
exit 0; |
fi |
|
# the new maildir doesn't exist the old one exists - move it |
mv "${ROOT}${OLD}" "${ROOT}${NEW}" || { echo "Cannot move maildir"; exit 5; } |
exit 2; |
fi |
|
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |