from __future__ import print_function, division #################################################################### ###### Copyright (c) 2015-2019 BigSQL ########## #################################################################### import os, sys import util, startup pgver = "pg9X" autostart = util.get_column('autostart', pgver) if autostart != "on": sys.exit(0) dotver = pgver[2] + "." + pgver[3] APG_HOME = os.getenv('APG_HOME', '') svcname = util.get_column('svcname', pgver, 'PostgreSQL ' + dotver + ' Server') if util.get_platform() == "Windows": sc_path = os.getenv("SYSTEMROOT", "") + os.sep + "System32" + os.sep + "sc" command = sc_path + ' delete "' + svcname + '"' util.system(command, is_admin=True) elif util.get_platform() == "Linux": startup.remove_linux("postgresql" + pgver[2:4], "85", "15")
pg_log = os.path.join(data_root_logs, pgver) if not os.path.isdir(pg_log): os.mkdir(pg_log) util.set_column("logdir", pgver, pg_log) if args.svcname > '': util.set_column("svcname", pgver, args.svcname) ## AUTOSTART ########################################### if ((args.autostart is None) or (autostart == args.autostart)): sys.exit(0) systemsvc = 'postgresql' + pgver[2:4] if args.autostart == "off": startup.remove_linux(systemsvc, pgver) else: pg_ctl = os.path.join(MY_HOME, pgver, 'bin', 'pg_ctl') pgdata = util.get_column('datadir', pgver) cmd_start = pg_ctl + ' start -D ' + pgdata + ' -s -w -t 300' cmd_stop = pg_ctl + ' stop -D ' + pgdata + ' -s -m fast' cmd_reload = pg_ctl + ' reload -D ' + pgdata + ' -s' cmd_status = pg_ctl + ' status -D ' + pgdata cmd_log = '-l ' + pgdata + '/pgstartup.log' svcuser = util.get_column('svcuser', pgver) startup.config_linux(pgver, systemsvc, svcuser, cmd_start, cmd_log, cmd_stop, cmd_reload, cmd_status) util.set_column('svcname', pgver, systemsvc) util.set_column('autostart', pgver, args.autostart) sys.exit(0)
subprocess.Popen(launctl_unload_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate() remove_existing_plist_link = "rm " + os.path.join(LAUNCHDIR, file_name) subprocess.Popen(remove_existing_plist_link, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate() elif util.get_platform() == 'Linux': systemsvc = 'postgresql' + pgver[2:4] start_lvl = "85" kill_lvl = "15" if args.autostart == "off": startup.remove_linux(systemsvc, start_lvl, kill_lvl) else: pg_ctl = os.path.join(MY_HOME, pgver, 'bin', 'pg_ctl') pgdata = util.get_column('datadir', pgver) cmd_start = pg_ctl + ' start -D ' + pgdata + ' -s -w -t 300' cmd_stop = pg_ctl + ' stop -D ' + pgdata + ' -s -m fast' cmd_reload = pg_ctl + ' reload -D ' + pgdata + ' -s' cmd_status = pg_ctl + ' status -D ' + pgdata cmd_log = '-l ' + pgdata + '/pgstartup.log' svcuser = util.get_column('svcuser', pgver) startup.config_linux(pgver, systemsvc, start_lvl, kill_lvl, svcuser, cmd_start, cmd_log, cmd_stop, cmd_reload, cmd_status) util.set_column('svcname', pgver, systemsvc) util.set_column('autostart', pgver, args.autostart)
from __future__ import print_function, division #################################################################### ###### Copyright (c) 2020-2021 PGSQL.IO ########## #################################################################### import os, sys import util, startup pgver = "pg9X" autostart = util.get_column('autostart', pgver) if autostart != "on": sys.exit(0) startup.remove_linux("postgresql" + pgver[2:4], pgver)