Skip to content
Snippets Groups Projects
Commit 0857307d authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Removed old startup script (refs #25525).

parent c4d1384c
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import utils
def setup(interactive=True):
dir_path = utils.get_dir(__file__)
# This script should be installed only if the home partition is a mount point
if not os.path.isfile('/etc/rc.local'):
utils.log('The /etc/rc.local file does not exists, action skipped. See ticket "https://redmine.ubicast.net/issues/25525".')
return
cmds = [
dict(line='write', template='%s/check_services.py' % dir_path, target='/usr/local/bin/check_services.py'),
'chmod 755 /usr/local/bin/check_services.py',
'cat /etc/rc.local | grep "/usr/local/bin/check_services.py" || sed -i "s/^exit 0/\(sleep 200 \&\& \/usr\/local\/bin\/check_services\.py \&\)\\n\\nexit 0/g" /etc/rc.local',
]
utils.run_commands(cmds)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
This script checks services that require /home are started.
If /home is not mounted, a mail is sent and in the other case,
it checks that all services that depend on /home are started.
'''
import datetime
import imp
import os
import socket
import sys
import time
if __name__ == '__main__':
ec = os.system('cat /etc/fstab | grep /home')
if ec != 0:
# /home is not a mount point
print('/home is not a mount point.')
sys.exit(0)
ec = os.system('mount | grep /home')
if ec == 0:
# /home is correctly mounted
sys.exit(0)
time.sleep(10)
os.system('mount -a')
ec = os.system('mount | grep /home')
if ec != 0:
time.sleep(60)
os.system('mount -a')
ec = os.system('mount | grep /home')
if ec != 0:
# Mounting has failed, send a email to warn admins
if os.path.exists('/etc/mediaserver/msconf.py'):
from django.conf import settings
config = imp.load_source('config', '/etc/mediaserver/msconf.py')
settings.configure(**config.__dict__)
from django.core.mail import send_mail
send_mail(
'The system %s did not correctly mount home partition' % socket.gethostname(),
'Date: %s' % datetime.datetime.now(),
'"%s" <support@ubicast.eu>' % socket.gethostname(),
['"Support" <support@ubicast.eu>'],
fail_silently=True
)
else:
os.system('service mediaserver restart')
os.system('service msmonitor restart')
os.system('service campus-manager restart')
......@@ -51,7 +51,6 @@ mediaserver() {
python3 /root/envsetup/envsetup.py 71
python3 /root/envsetup/envsetup.py 25
python3 /root/envsetup/envsetup.py 51
python3 /root/envsetup/envsetup.py 52
python3 /root/envsetup/envsetup.py 25
}
......@@ -76,7 +75,7 @@ cache() {
}
bench() {
python3 /root/envsetup/envsetup.py 53
python3 /root/envsetup/envsetup.py 52
}
tests() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment