package.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import os, pwd, socket
  4. pid_dir = "/run/firebird"
  5. log_file = "/var/log/firebird.log"
  6. uid = pwd.getpwnam("firebird")[2]
  7. hostname = socket.gethostname()
  8. def touch(filename):
  9. try:
  10. f = open(filename, "w")
  11. f.close()
  12. except IOError:
  13. fail("Failed to create %s file" % filename)
  14. def postInstall(fromVersion, fromRelease, toVersion, toRelease):
  15. # # Configure PID directory
  16. os.chown(pid_dir, uid, -1)
  17. # Create log file
  18. touch(log_file)
  19. os.chown(log_file, uid, -1)
  20. os.chmod(log_file, 0644)
  21. # Configure security2.fdb file
  22. os.chown("/opt/firebird/security2.fdb", uid, -1)
  23. # Create lock files
  24. for lock_filename in ("isc_guard1", "isc_init1", "isc_lock1"):
  25. lock_filename = "/opt/firebird/%s.%s" % (lock_filename, hostname)
  26. touch(lock_filename)
  27. os.chown(lock_filename, uid, -1)
  28. os.chmod(lock_filename, 0644)
  29. def preRemove():
  30. # Remove lock files
  31. for lock_filename in ("isc_guard1", "isc_init1", "isc_lock1"):
  32. lock_filename = "/opt/firebird/%s.%s" % (lock_filename, hostname)
  33. if os.path.exists(lock_filename):
  34. os.remove(lock_filename)