Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Services in Admin Console #475

Merged
merged 12 commits into from
Apr 17, 2022
15 changes: 11 additions & 4 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export ANSIBLE_LOG_PATH="$IIAB_ADMIN_DIR/admin-install.log"
#ansible-playbook -i $INVENTORY $PLAYBOOK --extra-vars "${ARGS}" --connection=local
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local

# Start CMDSRV
echo "(Re)Starting CMDSRV"
systemctl enable iiab-cmdsrv
systemctl restart iiab-cmdsrv

if [[ "$1" == "-n" ]]; then
echo "WARNING: THIS CAN CAUSE PROBLEMS"
echo "Only do this if a full install has already completed"
Expand All @@ -47,11 +52,13 @@ else

iiab-get-kiwix-cat -v
iiab-get-oer2go-cat
iiab-make-kiwix-lib
if [ -f /usr/bin/iiab-make-kiwix-lib ]
then
iiab-make-kiwix-lib
fi
iiab-update-menus
fi

# Start CMDSRV
echo "(Re)Starting CMDSRV"
systemctl enable iiab-cmdsrv
# Restart CMDSRV
echo "(Restarting CMDSRV"
systemctl restart iiab-cmdsrv
28 changes: 28 additions & 0 deletions roles/cmdsrv/files/iiab-cmdsrv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,24 @@ def get_oer2go_catalog(cmd_info):

def set_config_vars(cmd_info):
config_vars = cmd_info['cmd_args']['config_vars']
# adjust install state as necessary
# front end only sends enabled
# for user settable service roles
# if enabled true set install to true
# if enabled false and rolestatus install false set install to false
read_iiab_roles_stat()
fix_install = {}
for var in config_vars:
if '_enabled' in var:
role = var.split('_enabled')[0]
if role in iiab_roles_status: # settable role
if config_vars[var]: # enabled is true
fix_install[role + '_install'] = True # enabled so install is implied
else: # enabled false
if not iiab_roles_status[role]['active']: # not active so assume not installed
fix_install[role + '_install'] = False

config_vars = {**config_vars, **fix_install}
adm.write_iiab_local_vars(config_vars)
#print config_vars
resp = cmd_success(cmd_info['cmd'])
Expand Down Expand Up @@ -1782,10 +1800,16 @@ def run_ansible_roles(cmd_info):
# assemble /opt/iiab/iiab/run-roles-tmp.yml
# run it with ansible_playbook_program
# ToDo allow delta local vars as optional parameter
# Allow network as optional role

global ansible_running_flag
global jobs_requested

add_network = False

if 'cmd_args' in cmd_info:
add_network = cmd_info['cmd_args']['add_network'] # force network role to run

if ansible_running_flag:
return (cmd_error(msg="Ansible Command already Running."))

Expand Down Expand Up @@ -1833,6 +1857,10 @@ def run_ansible_roles(cmd_info):
lines.append(' - { role: ' + run_role + ' }\n')
role_cnt += 1

if add_network:
lines.append(' - { role: network }\n')
role_cnt += 1

if role_cnt == 0:
resp = cmd_error(msg='All Roles are already As Requested.')
return resp
Expand Down
1 change: 1 addition & 0 deletions roles/cmdsrv/templates/scripts/get_oer2go_catalog3.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def get_oer2go_cat():
except (urllib.error.URLError) as exc:
err_str = "GET-OER2GO-CAT ERROR - " + str(exc.reason) +'\n'
err_num = 1
oer2go_catalog_json = None

# except (RemoteDisconnected) as exc: # where do I import this exception?
# err_str = "GET-OER2GO-CAT ERROR - Remote end closed connection without response\n"
Expand Down