Changeset View
Changeset View
Standalone View
Standalone View
pykolab/setup/__init__.py
Show All 15 Lines | |||||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | # | ||||
import os | import os | ||||
import sys | import sys | ||||
import pykolab | import pykolab | ||||
from pykolab.translate import _ | |||||
log = pykolab.getLogger('pykolab.setup') | log = pykolab.getLogger('pykolab.setup') | ||||
conf = pykolab.getConf() | conf = pykolab.getConf() | ||||
to_execute = [] | to_execute = [] | ||||
class Setup(object): | class Setup(object): | ||||
def __init__(self): | def __init__(self): | ||||
import components | import components | ||||
components.__init__() | components.__init__() | ||||
arg_num = 0 | arg_num = 0 | ||||
for arg in sys.argv[1:]: | for arg in sys.argv[1:]: | ||||
arg_num += 1 | arg_num += 1 | ||||
if not arg.startswith('-') and len(sys.argv) >= arg_num: | if not arg.startswith('-') and len(sys.argv) >= arg_num: | ||||
if components.components.has_key(sys.argv[arg_num].replace('-','_')): | if components.components.has_key(sys.argv[arg_num].replace('-','_')): | ||||
to_execute.append(sys.argv[arg_num].replace('-','_')) | to_execute.append(sys.argv[arg_num].replace('-','_')) | ||||
def run(self): | def run(self): | ||||
if os.path.isfile('/sys/fs/selinux/enforce'): | |||||
if os.access('/sys/fs/selinux/enforce', os.R_OK): | |||||
# Set a gentle default because strictly speaking, | |||||
# setup won't fail (run-time does) | |||||
enforce = "0" | |||||
with open('/sys/fs/selinux/enforce', 'r') as f: | |||||
enforce = f.read() | |||||
if enforce.strip() == "1": | |||||
log.fatal( | |||||
_("SELinux currently enforcing. Read " + \ | |||||
"https://git.kolab.org/u/1") | |||||
) | |||||
sys.exit(1) | |||||
if os.path.isfile('/etc/selinux/config'): | |||||
if os.access('/etc/selinux/config', os.R_OK): | |||||
with open('/etc/selinux/config', 'r') as f: | |||||
for line in f: | |||||
if line.strip() == "SELINUX=enforcing": | |||||
log.fatal( | |||||
_("SELinux configured to enforce a " + \ | |||||
"policy on startup. Read " + \ | |||||
"https://git.kolab.org/u/1") | |||||
) | |||||
sys.exit(1) | |||||
components.execute('_'.join(to_execute)) | components.execute('_'.join(to_execute)) | ||||
if os.path.exists('/tmp/kolab-setup-my.cnf'): | if os.path.exists('/tmp/kolab-setup-my.cnf'): | ||||
os.unlink('/tmp/kolab-setup-my.cnf') | os.unlink('/tmp/kolab-setup-my.cnf') | ||||