|
1 |
| -## Get the training repository name and replace it with the placeholder string in different files |
2 |
| -REPONAME=$(basename `git rev-parse --show-toplevel`) |
3 |
| -echo -ne "Initializing $REPONAME . . . " |
4 |
| -sed -i "s/REPLACEREPONAME/${REPONAME}/g" *.* > /dev/null 2>&1 |
5 |
| -sed -i "s/REPLACEREPONAME/${REPONAME}/g" supplemental-ui/partials/header-content.hbs > /dev/null 2>&1 |
6 |
| -echo -e "done" |
7 |
| - |
8 |
| -mv -f README-TRAINING.md README.md |
9 |
| - |
10 |
| -## Automation required for repo customization (like for example TYPE hol or bfx LAB demo or role or other) goes here. |
11 | 1 | print_usage()
|
12 | 2 | {
|
13 | 3 | echo -e """
|
14 | 4 | USAGE: $0 --type [hol|bfx] --lab [demo|role|other]
|
15 |
| - DEFAULT: $0 --type hol --lab demo |
16 | 5 | """
|
17 | 6 | return
|
18 | 7 | }
|
| 8 | + |
| 9 | +exit_script() |
| 10 | +{ |
| 11 | + #cleanup |
| 12 | + echo -e "\nPlease replace the FIXME string in the antora.yml file below and commit the changes before proceeding with the course development." |
| 13 | + grep FIXME antora.yml |
| 14 | +} |
| 15 | + |
19 | 16 | handle_lab()
|
20 | 17 | {
|
21 |
| - case "$1" in |
22 |
| - "demo"|"role"|"other" ) |
23 |
| - LAB=$(echo $1) |
24 |
| - ;; |
25 |
| - * ) |
26 |
| - print_usage |
27 |
| - exit 1 |
28 |
| - ;; |
29 |
| - esac |
| 18 | + cp -f modules/LABENV/pages/index-lab-$LAB.adoc modules/LABENV/pages/index.adoc |
30 | 19 | }
|
| 20 | + |
31 | 21 | handle_type()
|
32 | 22 | {
|
33 |
| - case "$1" in |
34 |
| - "hol"|"bfx" ) |
35 |
| - TYPE=$(echo $1) |
| 23 | + case "$TYPE" in |
| 24 | + "hol" ) |
| 25 | + rm -rf modules.bfx |
| 26 | + ;; |
| 27 | + "bfx" ) |
| 28 | + rm -rf modules |
| 29 | + mv modules.bfx modules |
36 | 30 | ;;
|
37 | 31 | * )
|
| 32 | + echo -e "ERROR: you should never land here" |
38 | 33 | print_usage
|
39 | 34 | exit 1
|
40 | 35 | ;;
|
41 | 36 | esac
|
42 | 37 | }
|
| 38 | + |
43 | 39 | execute_init()
|
44 | 40 | {
|
45 |
| - echo -e "Initializing type to $TYPE and lab to $LAB " |
46 |
| - mv -f modules/LABENV/pages/index-lab-$LAB.adoc modules/LABENV/pages/index.adoc |
47 |
| - echo -e "TODO: Handling course type is not implemented yet" |
48 |
| - exit 0 |
| 41 | + ## Get the training repository name and replace it with the placeholder string in different files |
| 42 | + handle_type |
| 43 | + handle_lab |
| 44 | + REPONAME=$(basename `git rev-parse --show-toplevel`) |
| 45 | + echo -ne "Initializing $REPONAME . . . " |
| 46 | + sed -i "s/course-starter-template/${REPONAME}/g" *.* > /dev/null 2>&1 |
| 47 | + sed -i "s/course-starter-template/${REPONAME}/g" supplemental-ui/partials/header-content.hbs > /dev/null 2>&1 |
| 48 | + echo -e "done" |
| 49 | + |
| 50 | + mv -f README-TRAINING.md README.md |
| 51 | +} |
| 52 | + |
| 53 | +validate_args() |
| 54 | +{ |
| 55 | + case "$LAB" in |
| 56 | + "demo"|"role"|"other" ) |
| 57 | + ;; |
| 58 | + * ) |
| 59 | + echo -e "ERROR: Invalid lab type: $LAB" |
| 60 | + print_usage |
| 61 | + exit 1 |
| 62 | + ;; |
| 63 | + esac |
| 64 | + case "$TYPE" in |
| 65 | + "hol"|"bfx" ) |
| 66 | + ;; |
| 67 | + * ) |
| 68 | + echo -e "ERROR: Invalid course type: $TYPE" |
| 69 | + print_usage |
| 70 | + exit 1 |
| 71 | + ;; |
| 72 | + esac |
| 73 | + execute_init |
| 74 | + echo -e "Initialized type to $TYPE and lab to $LAB " |
| 75 | + exit_script |
| 76 | +} |
| 77 | + |
| 78 | +cleanup() |
| 79 | +{ |
| 80 | + # Clean unused files for lab type |
| 81 | + rm -f modules/LABENV/pages/index-*.adoc |
| 82 | + # Clean unused files for course type |
| 83 | + # Remove this script |
| 84 | + rm -f $0 |
49 | 85 | }
|
| 86 | + |
| 87 | +## Start by validating provided options and initializing variables for arguments |
| 88 | +if [ $# -lt 4 ] |
| 89 | +then |
| 90 | + echo -e "ERROR: Insufficient arguments" |
| 91 | + print_usage |
| 92 | + exit 1 |
| 93 | +fi |
| 94 | + |
50 | 95 | for arg in "$@"
|
51 | 96 | do
|
52 | 97 | case ${arg} in
|
53 | 98 | "--lab" )
|
54 | 99 | shift
|
55 |
| - handle_lab $1 |
| 100 | + LAB=$(echo $1) |
56 | 101 | shift
|
57 | 102 | ;;
|
58 | 103 | "--type" )
|
59 | 104 | shift
|
60 |
| - handle_type $1 |
| 105 | + TYPE=$(echo $1) |
61 | 106 | shift
|
62 | 107 | ;;
|
63 | 108 | "--help" )
|
|
66 | 111 | ;;
|
67 | 112 | esac
|
68 | 113 | done
|
69 |
| -execute_init |
70 | 114 |
|
71 |
| -#cleanup() |
72 |
| -echo -e "\nPlease replace the specified strings in the files below and commit the changes before proceeding with the course development." |
73 |
| -grep FIXME *.* |
| 115 | +validate_args |
| 116 | + |
74 | 117 |
|
75 |
| -cleanup() |
76 |
| -{ |
77 |
| - # Clean unused files for lab type |
78 |
| - rm -f modules/LABENV/pages/index-*.adoc |
79 |
| - # Clean unused files for course type |
80 |
| - # Remove this script |
81 |
| - rm -f $0 |
82 |
| -} |
|
0 commit comments