4. Administration

The script applicants-admin.sh provides an administration shell to manage applicant accounts.

4.1. Diagrams

(see figure 4.1)

@startuml /' a0 '/
skinparam padding 1
partition "applicants-admin" {
start
floating note right
applicants-admin.sh - setup applicant accounts

usage: applicants-admin.sh [OPTIONS] [ACTION [ARGS]]

ACTION
| action    | args            | description                                                        |
| status    | [ACCT NAME ..]  | show status for accounts (default action)\n (default all accounts) |
| check     | [ACCT NAME ..]  | check workpackage for accounts\n (default all accounts)            |
| passwords | [ACCT NAME ..]  | show VNC passwords for accounts\n (default all accounts)           |
| links     | [ACCT NAME ..]  | display links for index page                                       |
| create    | [COUNT [START]] | create accounts\n (default COUNT: 4)                               |
| disable   | [ACCT NAME ..]  | disable accounts\n (default all accounts)                          |
| archive   | [ACCT NAME ..]  | archive accounts\n (default all accounts)                          |
| delete    | [ACCT NAME ..]  | delete accounts\n (default all accounts)\n implies //disable// and //archive// |

OPTIONS
-d, --debug  do not execute commands
end note
:parse argument ACTION, default: status;
    if (action == status?) then (yes)
    :run as root|
    :show status
    of applicants|
    elseif (action == check?) then (yes)
    :check workpackage
    of applicants|
    elseif (action == passwords?) then (yes)
    :run as root|
    :show passwords
    of applicants|
    elseif (action == links?) then (yes)
    :display links
    for index page|
    elseif (action == create?) then (yes)
    :run as root|
    :create applicants|
    elseif (action == disable?) then (yes)
    :run as root|
    :disable applicants|
    elseif (action == archive?) then (yes)
    :run as root|
    :archive applicants|
    elseif (action == delete?) then (yes)
    :run as root|
    :delete applicants|
    else
    :error message;
    end
    endif
stop
}
partition "run as root" {
start
if (root) then (yes)
    :install packages;
else
: exec as root;
end
endif
stop
}
partition "show status of applicants" {
    start
    while (for each _applicant) is (do)
        :show status of applicant;
    endwhile  ( )
    stop
}
partition "check workpackage of applicants" {
    start
    while (for each _applicant) is (do)
        :check workpackage of applicant|
    endwhile
    stop
}
partition "check workpackage of applicant" {
        start
        if (_applicant == "."?) then (yes)
            :use basename of current directory;
        endif
        if (workpackage directory does not exist?) then (yes)
            :error message;
            end
        endif
        :enter check directory;
        :link workpackge database;
        if (workpackage database does not exist?) then (yes)
            :error message;
            end
        endif
        :show schema of workpackage database;
        :* generate pristine version of
          workpackage_db.py from database
        * check whether it works;
        if (applicant's workpackage_db.py does not exist?) then (yes)
            :error message;
            end
        endif
        :* compare pristine workpackage_db.py
          with applicant's version
        * check whether it works;
        stop
}
partition "show passwords of applicants" {
    start
    while (for each _applicant) is (do)
        :show password of applicant;
    endwhile
    stop
}
partition "display links for index page" {
    start
    while (for each _applicant) is (do)
        :show link for applicant;
    endwhile
    stop
}
partition "create applicants" {
    start
    :default count: 4;
    :default start: 1;
    while (**for** _indx **in** start **to** count) is (do)
        :create applicant;
        if (user does not exist?) then (yes)
            :create group;
            :create user;
        else  ( )
            :warning message;
        endif
        :install profiles, if not installed;
        :show README-vnc.html on login;
        :install emacs init;
        :install snippets;
        :create ssh key;
        :create authorized_keys file;
        :create project links;
        :get master password
        read/generate password;
        :store vnc password and VNC documentation;
        :install VNC server;
        :run Emacs on X startup;
        :install Firefox profile;
        :store apache password;
        :create apache configuration;
        :generate applicant access data archive;
    endwhile  ( )
    stop
}
partition "disable applicants" {
    start
    while (for each _applicant) is (do)
        :disable applicant|
    endwhile  ( )
    stop
}
partition "archive applicants" {
    start
    while (for each _applicant) is (do)
        :archive current applicant|
    endwhile  ( )
    stop
}
partition "delete applicants" {
    start
    while (for each _applicant) is (do)
        :disable current applicant|
        :archive current applicant|
        :delete current applicant;
    endwhile  ( )
    stop
}
@enduml

figure 4.1 Applicants administration shell

4.1.1. Functions

(see figure 4.2)

@startuml /' a1 '/
skinparam padding 1
partition "list applicants" {
start
while (for each _dir in /home/applicant*) is (do)
    if (_dir is readable?) then (yes)
    :print user name;
    endif
endwhile
stop
}
@enduml

figure 4.2 List all applicants