Browse Source

Restyling Packaging

Change-Id: I1da9ba514df9f4aae0efec081bcb4697855d5a20
changes/18/604418/1
Nicola Peditto 4 years ago
parent
commit
2e3da1ab45
  1. 12
      MANIFEST.in
  2. 11
      etc/logrotate.d/lightning-rod.log
  3. 28
      scripts/configure_lr.py
  4. 103
      scripts/install_lr.py
  5. 2
      setup.cfg
  6. 18
      setup.py
  7. 0
      templates/plugins.example.json
  8. 0
      templates/services.example.json
  9. 0
      templates/settings.example.json

12
MANIFEST.in

@ -1,6 +1,16 @@
include etc/iotronic/iotronic.conf
include templates/settings.example.json
include templates/plugins.example.json
include templates/services.example.json
include etc/systemd/system/s4t-lightning-rod.service
include etc/logrotate.d/lightning-rod.log
include scripts/install_lr.py
include scripts/configure_lr.py
include AUTHORS
include ChangeLog
exclude .gitignore
exclude .gitreview
global-exclude *.pyc
global-exclude *.pyc

11
etc/logrotate.d/lightning-rod.log

@ -0,0 +1,11 @@
/var/log/iotronic/lightning-rod.log /var/log/wstun/wstun.log{
copytruncate
create
missingok
weekly
rotate = 3
compress
notifempty
su root root
maxsize 5M
}

28
scripts/configure_lr.py

@ -0,0 +1,28 @@
# Copyright 2017 MDSLAB - University of Messina
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# !/usr/bin/python3
import os
import sys
if len(sys.argv) < 3:
print('Arguments required: "<REGISTRATION-TOKEN> <WAMP-REG-AGENT-URL>',
str(sys.argv))
else:
os.system('sed -i "s|<REGISTRATION-TOKEN>|'
+ sys.argv[1] + '|g" /etc/iotronic/settings.json')
os.system('sed -i "s|ws://<WAMP-SERVER>:<WAMP-PORT>/|'
+ sys.argv[2] + '|g" /etc/iotronic/settings.json')
os.system('sed -i "s|<IOTRONIC-REALM>|s4t|g" /etc/iotronic/settings.json')

103
scripts/install_lr.py

@ -0,0 +1,103 @@
# Copyright 2017 MDSLAB - University of Messina
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# !/usr/bin/python3
import os
import site
py_dist_pack = site.getsitepackages()[0]
print(py_dist_pack)
print('Iotronic environment creation:')
if not os.path.exists('/etc/iotronic/'):
os.makedirs('/etc/iotronic/', 0o644)
print(' - /etc/iotronic/ - Created.')
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/'
+ 'templates/settings.example.json /etc/iotronic/settings.json')
print(' - settings.json - Created.')
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/'
+ 'etc/iotronic/iotronic.conf /etc/iotronic/iotronic.conf')
print(' - iotronic.conf - Created.')
else:
print(' - /etc/iotronic/ - Already exists.')
if not os.path.isfile('/etc/iotronic/settings.json'):
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/templates/'
+ 'settings.example.json /etc/iotronic/settings.json')
print(' - settings.json - Created.')
else:
print(' - settings.json - Already exists.')
if not os.path.isfile('/etc/iotronic/iotronic.conf'):
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/'
+ 'etc/iotronic/iotronic.conf /etc/iotronic/iotronic.conf')
print(' - iotronic.conf - Created.')
else:
print(' - iotronic.conf - Already exists.')
if not os.path.exists('/var/lib/iotronic/'):
os.makedirs('/var/lib/iotronic/plugins', 0o644)
print(' - /var/lib/iotronic/plugins - Created.')
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/templates/'
+ 'plugins.example.json /var/lib/iotronic/plugins.json')
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/templates/'
+ 'services.example.json /var/lib/iotronic/services.json')
print(' - configuration files added.')
else:
print(' - /var/lib/iotronic/ - Already exists.')
if not os.path.isfile('/var/lib/iotronic/plugins.json'):
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/templates/'
+ 'plugins.example.json /var/lib/iotronic/plugins.json')
print(' - plugins.json - Created.')
else:
print(' - plugins.json - Already exists.')
if not os.path.isfile('/var/lib/iotronic/services.json'):
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/templates/'
+ 'services.example.json /var/lib/iotronic/services.json')
print(' - services.json - Created.')
else:
print(' - services.json - Already exists.')
print('Logging configuration: ')
if not os.path.exists('/var/log/iotronic/'):
os.makedirs('/var/log/iotronic/', 0o644)
print(' - /var/log/iotronic/ - Created.')
else:
print(' - /var/log/iotronic/ - Already exists.')
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/etc/logrotate.d/'
+ 'lightning-rod.log /etc/logrotate.d/lightning-rod.log')
print(' - logrotate configured.')
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/etc/systemd/system/'
+ 's4t-lightning-rod.service '
+ '/etc/systemd/system/lightning-rod.service')
os.chmod('/etc/systemd/system/lightning-rod.service', 0o744)
print('Lightning-rod systemd script installed.')
from subprocess import call
call(["systemctl", "enable", "lightning-rod.service"])
call(["systemctl", "daemon-reload"])
os.system('cp ' + py_dist_pack + '/iotronic_lightningrod/scripts/'
+ 'configure_lr.py /usr/bin/configure_lr')
os.chmod('/usr/bin/configure_lr', 0o744)

2
setup.cfg

@ -64,3 +64,5 @@ s4t.modules =
[options]
build_scripts =
executable= /usr/bin/env python

18
setup.py

@ -27,5 +27,21 @@ except ImportError:
setuptools.setup(
setup_requires=['pbr>=1.8'],
pbr=True,
include_package_data=True,
data_files=[
('/iotronic_lightningrod/etc/iotronic',
['etc/iotronic/iotronic.conf']),
('/iotronic_lightningrod/scripts', ['scripts/install_lr.py']),
('/iotronic_lightningrod/scripts', ['scripts/configure_lr.py']),
('/iotronic_lightningrod/templates',
['templates/settings.example.json']),
('/iotronic_lightningrod/templates',
['templates/plugins.example.json']),
('/iotronic_lightningrod/templates',
['templates/services.example.json']),
('/iotronic_lightningrod/etc/logrotate.d',
['etc/logrotate.d/lightning-rod.log']),
('/iotronic_lightningrod/etc/systemd/system/',
['etc/systemd/system/s4t-lightning-rod.service']),
],
)

0
plugins.example.json → templates/plugins.example.json

0
services.example.json → templates/services.example.json

0
settings.example.json → templates/settings.example.json

Loading…
Cancel
Save