@@ -9,25 +9,25 @@ SSM_CMD_INSTALL_LOADED=1
99ssm_cmd_install () {
1010 local target_kind=" ${1:- } "
1111 local target_name=" ${2:- } "
12- [[ -n " ${target_kind} " ]] || ssm_die " Missing install target kind"
13- [[ -n " ${target_name} " ]] || ssm_die " Missing install target name"
12+ [[ -n " ${target_kind} " ]] || ssm_die " Missing install target"
1413
1514 local project_dir
1615 project_dir=" $( ssm_find_project_dir " ${SSM_CLI_PROJECT_DIR:- } " ) "
16+ ssm_resolve_target_spec " ${project_dir} " " ${target_kind} " " ${target_name} "
1717 local render_dir
1818 render_dir=" $( mktemp -d) "
1919 trap ' rm -rf ' " '" ${render_dir} " '" ' ' RETURN
2020
2121 local source_file=" "
2222 local scope=" system"
2323
24- case " ${target_kind } " in
24+ case " ${SSM_RESOLVED_TARGET_KIND } " in
2525 service)
26- ssm_parse_service_config " ${project_dir} " " ${target_name } "
26+ ssm_parse_service_config " ${project_dir} " " ${SSM_RESOLVED_TARGET_NAME } "
2727 ssm_require_safe_name " UNIT_PREFIX" " ${UNIT_PREFIX} "
28- source_file=" $( ssm_service_config_path " ${project_dir} " " ${target_name } " ) "
28+ source_file=" $( ssm_service_config_path " ${project_dir} " " ${SSM_RESOLVED_TARGET_NAME } " ) "
2929 scope=" ${SSM_SERVICE_SCOPE} "
30- local service_unit_file=" ${render_dir} /$( ssm_service_unit_name " ${target_name } " ) "
30+ local service_unit_file=" ${render_dir} /$( ssm_service_unit_name " ${SSM_RESOLVED_TARGET_NAME } " ) "
3131 ssm_render_service_unit " ${source_file} " > " ${service_unit_file} "
3232 ssm_verify_unit_file " ${service_unit_file} " || ssm_die " systemd-analyze verify failed for ${service_unit_file} "
3333 if [[ " ${SSM_CLI_DRY_RUN} " == " 1" ]]; then
@@ -37,18 +37,24 @@ ssm_cmd_install() {
3737 mkdir -p " $( ssm_unit_dir_for_scope " ${scope} " ) "
3838 cp " ${service_unit_file} " " $( ssm_unit_dir_for_scope " ${scope} " ) /"
3939 ssm_daemon_reload " ${scope} "
40+ printf ' installed=%s\n' " $( ssm_service_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
41+ if [[ " ${SSM_CLI_START_AFTER_INSTALL} " == " 1" ]]; then
42+ ssm_systemctl " ${scope} " start " $( ssm_service_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
43+ printf ' started=%s\n' " $( ssm_service_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
44+ fi
45+ ssm_print_unit_summary " ${SSM_RESOLVED_TARGET_NAME} " " ${scope} " " $( ssm_service_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
4046 ;;
4147 timer)
42- ssm_parse_timer_config " ${project_dir} " " ${target_name } "
48+ ssm_parse_timer_config " ${project_dir} " " ${SSM_RESOLVED_TARGET_NAME } "
4349 ssm_require_safe_name " UNIT_PREFIX" " ${UNIT_PREFIX} "
44- source_file=" $( ssm_timer_config_path " ${project_dir} " " ${target_name } " ) "
50+ source_file=" $( ssm_timer_config_path " ${project_dir} " " ${SSM_RESOLVED_TARGET_NAME } " ) "
4551 scope=" ${SSM_TIMER_SCOPE} "
4652 local schedule_block
4753 schedule_block=" $( ssm_resolve_schedule " ${SCHEDULE} " ) "
4854 local task_unit_name
49- task_unit_name=" $( ssm_timer_task_unit_name " ${target_name } " ) "
55+ task_unit_name=" $( ssm_timer_task_unit_name " ${SSM_RESOLVED_TARGET_NAME } " ) "
5056 local task_unit_file=" ${render_dir} /${task_unit_name} "
51- local timer_unit_file=" ${render_dir} /$( ssm_timer_unit_name " ${target_name } " ) "
57+ local timer_unit_file=" ${render_dir} /$( ssm_timer_unit_name " ${SSM_RESOLVED_TARGET_NAME } " ) "
5258 local task_exec_command=" "
5359
5460 if [[ " ${TARGET_TYPE} " == " service" ]]; then
@@ -78,6 +84,12 @@ ssm_cmd_install() {
7884 cp " ${task_unit_file} " " $( ssm_unit_dir_for_scope " ${scope} " ) /"
7985 cp " ${timer_unit_file} " " $( ssm_unit_dir_for_scope " ${scope} " ) /"
8086 ssm_daemon_reload " ${scope} "
87+ printf ' installed=%s\n' " $( ssm_timer_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
88+ if [[ " ${SSM_CLI_START_AFTER_INSTALL} " == " 1" ]]; then
89+ ssm_systemctl " ${scope} " start " $( ssm_timer_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
90+ printf ' started=%s\n' " $( ssm_timer_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
91+ fi
92+ ssm_print_unit_summary " ${SSM_RESOLVED_TARGET_NAME} " " ${scope} " " $( ssm_timer_unit_name " ${SSM_RESOLVED_TARGET_NAME} " ) "
8193 ;;
8294 * )
8395 ssm_die " Unknown install target kind: ${target_kind} "
0 commit comments