-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flex-linux-setup): admin-ui command line utility (#1976)
Signed-off-by: Mustafa Baser <[email protected]>
- Loading branch information
1 parent
c8336ed
commit 6df74ea
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import sys | ||
import argparse | ||
import subprocess | ||
|
||
parser = argparse.ArgumentParser(description="Gluu/Flex Admin-UI command line utility") | ||
parser.add_argument('-restart', help="Restarts services for Janssen config-api and apache web server", action='store_true') | ||
argsp = parser.parse_args() | ||
|
||
if len(sys.argv) < 2: | ||
print("No argument was provided.") | ||
sys.exit() | ||
|
||
httpd_name = None | ||
for sname in ('httpd', 'apache2'): | ||
cmd = f'systemctl show --no-pager {sname} | grep LoadState=loaded' | ||
cmd_output = subprocess.getoutput(cmd).strip() | ||
if cmd_output: | ||
httpd_name = sname | ||
break | ||
if not httpd_name: | ||
print("\033[93mUnable to determine httpd server name\033[0m") | ||
sys.exit() | ||
|
||
if argsp.restart: | ||
print("Restarting Admin-UI components") | ||
for service in ('jans-config-api', httpd_name): | ||
cmd = f'sudo systemctl restart {service}' | ||
print(f"Executing {cmd}") | ||
out = subprocess.getoutput(cmd).strip() | ||
if out: | ||
print(f"Command output: {out}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters