|
|
@ -2,7 +2,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
from pwd import getpwnam
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
|
import shutil
|
|
|
|
import shutil
|
|
|
@ -78,17 +77,15 @@ conf.jinja("/defaults/php.ini", context, "/etc/php81/php.ini")
|
|
|
|
# setup permissions
|
|
|
|
# setup permissions
|
|
|
|
os.system("chown -R mailu:mailu /data")
|
|
|
|
os.system("chown -R mailu:mailu /data")
|
|
|
|
|
|
|
|
|
|
|
|
def demote(user_uid, user_gid):
|
|
|
|
def demote(username='mailu'):
|
|
|
|
def result():
|
|
|
|
def result():
|
|
|
|
os.setgid(user_gid)
|
|
|
|
system.drop_privs_to(username)
|
|
|
|
os.setuid(user_uid)
|
|
|
|
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
id_mailu = getpwnam('mailu')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("Initializing database")
|
|
|
|
print("Initializing database")
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
result = subprocess.check_output(["/var/www/roundcube/bin/initdb.sh", "--dir", "/var/www/roundcube/SQL"],
|
|
|
|
result = subprocess.check_output(["/var/www/roundcube/bin/initdb.sh", "--dir", "/var/www/roundcube/SQL"],
|
|
|
|
stderr=subprocess.STDOUT, preexec_fn=demote(id_mailu.pw_uid,id_mailu.pw_gid))
|
|
|
|
stderr=subprocess.STDOUT, preexec_fn=demote())
|
|
|
|
print(result.decode())
|
|
|
|
print(result.decode())
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
err = exc.stdout.decode()
|
|
|
|
err = exc.stdout.decode()
|
|
|
@ -100,13 +97,13 @@ except subprocess.CalledProcessError as exc:
|
|
|
|
|
|
|
|
|
|
|
|
print("Upgrading database")
|
|
|
|
print("Upgrading database")
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
subprocess.check_call(["/var/www/roundcube/bin/update.sh", "--version=?", "-y"], stderr=subprocess.STDOUT, preexec_fn=demote(id_mailu.pw_uid,id_mailu.pw_gid))
|
|
|
|
subprocess.check_call(["/var/www/roundcube/bin/update.sh", "--version=?", "-y"], stderr=subprocess.STDOUT, preexec_fn=demote())
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
exit(4)
|
|
|
|
exit(4)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print("Cleaning database")
|
|
|
|
print("Cleaning database")
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
subprocess.check_call(["/var/www/roundcube/bin/cleandb.sh"], stderr=subprocess.STDOUT, preexec_fn=demote(id_mailu.pw_uid,id_mailu.pw_gid))
|
|
|
|
subprocess.check_call(["/var/www/roundcube/bin/cleandb.sh"], stderr=subprocess.STDOUT, preexec_fn=demote())
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
exit(5)
|
|
|
|
exit(5)
|
|
|
|
|
|
|
|
|
|
|
|