summaryrefslogtreecommitdiffstats
path: root/sbin/sunhpc-completion-backup
blob: 82752d6ed3781c0b0e8de8951a603092b9253296 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#/usr/bin/env bash
_sunhpc()
{
    local cur prev words cword split
    _init_completion -s || return

    COMPREPLY=()
    _get_comp_words_by_ref -n : cur prev words

    # Command data: Main commands
    cmds='add build check create database list pxelinux repair report run set soft'

    # sunhpc add commands
    cmds_add='host security'
    cmds_add_host='interface security cpus= membership= os= rack= rank= help'
    cmds_add_host_interface='ip= mac= name= subnet= help'
    cmds_add_host_security='force= help'
    cmds_add_security='force= help'


    # sunhpc build commands
    cmds_build='init initializes'
    cmds_build_init='help'
    cmds_build_initializes='help'


    # sunhpc check commands
    cmds_check='services help'
    cmds_check_services='help'

    # sunhpc create commands
    cmds_create='distro pxelinux repos roll rpm security xml help'
    cmds_create_distro='arch= dist= md5= rolls= root= version= help'

    # sunhpc create pxelinux commands
    cmds_create_pxelinux='client efiboot kickstart product squashfs updates vminitrd'
    cmds_create_pxelinux_client='basedir= outdir= version= help'
    cmds_create_pxelinux_efiboot='basedir= outdir= cdrom= version= help'
    cmds_create_pxelinux_kickstart='basedir= outdir= version= help'
    cmds_create_pxelinux_product='basedir= outdir= version= help'
    cmds_create_pxelinux_squashfs='basedir= outdir= cdrom= version= help'
    cmds_create_pxelinux_updates='basedir= outdir= cdrom= version= help'
    cmds_create_pxelinux_vminitrd='basedir= outdir= cdrom= version= help'
    
    # sunhpc create repos commands
    cmds_create_repos='file= gpk= web=  help'

    # sunhpc create roll commands
    cmds_create_roll='boot= sign= help'

    # sunhpc create rpm commands
    cmds_create_rpm='arch= name= outdir= prefix= release= source= spec= version= help'

    # sunhpc create security commands
    cmds_create_security='sshd users keyname= force= help'
    cmds_create_security_sshd='help'
    cmds_create_security_users=' safedir= help'

    # sunhpc create xml commands
    cmds_create_xml=' arch= bin= boot= flag= name= os= release= rolls= src= version= help'

    # sunhpc database commands
    cmds_database='init help'
    cmds_database_init='help'

    # sunhpc list commands
    cmds_list='host license help'
    cmds_list_host='interface help'
    cmds_list_host_interface='help'
    cmds_list_license='help'

    # sunhpc pxelinux commands
    cmds_pxelinux='build help'
    cmds_pxelinux_build='autofs dhcpd httpd nodes tftpd clean= iso= mnt= pxesrv=  help'
    cmds_pxelinux_build_autofs='quiet=  help'
    cmds_pxelinux_build_dhcpd='quiet=  help'
    cmds_pxelinux_build_httpd='pxedir= quiet=  help'
    cmds_pxelinux_build_nodes='quiet=  help'
    cmds_pxelinux_build_tftpd='pxedir= quiet=  help'

    # sunhpc repair commands
    cmds_repair='permission users help'
    cmds_repair_permission='help'
    cmds_repair_users='authorized help'
    cmds_repair_users_authorized='all= help'

    # sunhpc report commands
    cmds_report='distro host kickstart knownhosts nextip yumrepos help'
    cmds_report_distro='help'
    cmds_report_host='attr dhcpd help'
    cmds_report_host_attr='attr= pydict= help'
    cmds_report_host_dhcpd='help'
    cmds_report_kickstart='help'
    cmds_report_knownhosts='help'
    cmds_report_nextip='baseip= increment= help'
    cmds_report_yumrepos='proto= url= help'

    # sunhpc run commands
    cmds_run='host help'
    cmds_run_host='collate= command= delay= managed= num-threads= stats= timeout= x11=  help'

    # sunhpc set commands
    cmds_set='grub host help'
    cmds_set_grub='default= help'
    cmds_set_host='boot cpus interface help'
    cmds_set_host_boot='action= help'
    cmds_set_host_cpus='cpus=  help'
    cmds_set_host_interface='iface ip mac name subnet help'
    cmds_set_host_interface_iface='iface= mac= help'
    cmds_set_host_interface_ip='iface= ip= help'
    cmds_set_host_interface_mac='iface= mac= help'
    cmds_set_host_interface_name='iface= name= help'
    cmds_set_host_interface_subnet='iface= subnet= help'

    # sunhpc soft commands
    cmds_soft='autodock cmake gaussian gromacs mpi ntfs nvidia openmpi schrodinger help'
    cmds_soft_autodock='envs= prefix= source= help'
    cmds_soft_cmake='envs= prefix= source= help'
    cmds_soft_gaussian='envs= prefix= source= help'
    cmds_soft_gromacs='envs= prefix= source= help'
    cmds_soft_mpi='envs= prefix= source= help'
    cmds_soft_ntfs='envs= prefix= source= help'
    cmds_soft_nvidia='envs= prefix= source= help'
    cmds_soft_openmpi='envs= prefix= source= help'
    cmds_soft_schrodinger='envs= prefix= source= help'

    # sunhpc sync commands
    cmds_sync='config users help'
    cmds_sync_config='help'
    cmds_sync_users='help'

    # sunhpc help commands.
    cmds_help='help'


    cmd=""
    words[0]=""
    completed="${cmds}"

    for var in "${words[@]:1}"
    do
        if [[ ${var} == -* ]] ; then
            break
        fi

        if [ -z "${cmd}" ] ; then
            proposed="${var}"
        else
            proposed="${cmd}_${var}"
        fi

        local i="cmds_${proposed}"
        local comp="${!i}"
        if [ -z "${comp}" ] ; then
            break
        fi

        if [[ ${comp} == -* ]] ; then
            if [[ ${cur} != -* ]] ; then
                completed=""
                break
            fi
        fi

        cmd="${proposed}"
        completed="${comp}"
    done

    if [ -z "${completed}" ] ; then
        COMPREPLY=( $(compgen -f -- "$cur" ) $( compgen -d -- "$cur" ) )
    else
         COMPREPLY=( $(compgen -W "${completed}" -- "${cur}") )
    fi

    # do not append a space to words that end with =
    #[[ $COMPREPLY == *= ]] && compopt -o nospace 
    [[ $COMPREPLY == *= ]] && compopt -o nospace || compopt -o dirnames

    #_available_interfaces

} &&
complete -F _sunhpc sunhpc