Completion pour OpenVZ (ZSH)
Voici un début de complétion pour OpenVZ:
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 |
#compdef vzctl _vzctl() { _arguments '--quiet[Quiet]' '--verbose[Verbose output]' '*::OpenVZ command:_OpenVZ_command' } (( $+functions[_OpenVZ_command] )) || _OpenVZ_command() { (($+_OpenVZ_cmds )) || _OpenVZ_cmds=( 'start:Start a VE' 'restart:Restart a VE' 'status:Show VE status' 'stop:Stop a VE' 'enter:Enter into a VE' 'mount:Mount VE private area' 'umount:Umount VE private area' 'set:Set various VE parameters' 'destroy:Destroy a zone' 'runscript:Run specified shell script into a VE' 'create:Create a new VE area' 'exec:Execute' 'exec2:Execute' ) if (( CURRENT == 1 )); then _describe -t commands 'OpenVZ command' _OpenVZ_cmds else local curcontext="$curcontext" cmd="${_OpenVZ_cmds[(r)$words[1]:*]%%:*}" if (( $#cmd )); then curcontext="${curcontext%:*:*}:OpenVZ-${cmd}:" _call_function ret _OpenVZ_$cmd || _message 'no more arguments' else _message "Unknow OpenVZ command: $words[1]" fi return ret fi } ### Utility functions ### OpenVZ functions (( $+functions[_OpenVZ_set] )) || _OpenVZ_set(){ #runvms=(${${(M)${(f)"$(vzlist -H -a -o veid,status,hostname)"}:#[[:blank:]]##[[:digit:]]*running*}/(#b)[[:blank:]]##([[:digit:]]##)[[:blank:]]##[[:alpha:]]##[[:blank:]]##/$match[1]:}) runvms=(${${(M)${(f)"$(vzlist -H -a -o veid,status,hostname)"}:#[[:blank:]]##[[:digit:]]**}/(#b)[[:blank:]]##([[:digit:]]##)[[:blank:]]##[[:alpha:]]##[[:blank:]]##/$match[1]:}) _arguments -s '1:veid:(($runvms))' '--onboot[yes|no]:onboot:(yes no)' '--root' '--userpasswd[user:passwd]' '--save' } (( $+functions[_OpenVZ_start] )) || _OpenVZ_start(){ runvms=(${${(M)${(f)"$(vzlist -H -a -o veid,status,hostname)"}:#[[:blank:]]##[[:digit:]]*stopped*}/(#b)[[:blank:]]##([[:digit:]]##)[[:blank:]]##[[:alpha:]]##[[:blank:]]##/$match[1]:}) _arguments -s '1:veid:(($runvms))' } (( $+functions[_OpenVZ_restart] )) || _OpenVZ_restart(){ runvms=(${${(M)${(f)"$(vzlist -H -a -o veid,status,hostname)"}:#[[:blank:]]##[[:digit:]]*stopped*}/(#b)[[:blank:]]##([[:digit:]]##)[[:blank:]]##[[:alpha:]]##[[:blank:]]##/$match[1]:}) _arguments -s '1:veid:(($runvms))' } (( $+functions[_OpenVZ_stop] )) || _OpenVZ_stop(){ runvms=(${${(M)${(f)"$(vzlist -H -a -o veid,status,hostname)"}:#[[:blank:]]##[[:digit:]]*running*}/(#b)[[:blank:]]##([[:digit:]]##)[[:blank:]]##[[:alpha:]]##[[:blank:]]##/$match[1]:}) _arguments -s '1:veid:(($runvms))' } (( $+functions[_OpenVZ_reload] )) || _OpenVZ_reload(){ runvms=(${${(M)${(f)"$(vzlist -H -a -o veid,status,hostname)"}:#[[:blank:]]##[[:digit:]]*running*}/(#b)[[:blank:]]##([[:digit:]]##)[[:blank:]]##[[:alpha:]]##[[:blank:]]##/$match[1]:}) _arguments -s '1:veid:(($runvms))' } (( $+functions[_OpenVZ_exec] )) || _OpenVZ_exec(){ } (( $+functions[_OpenVZ_exec2] )) || _OpenVZ_exec2(){ } (( $+functions[_OpenVZ_enter] )) || _OpenVZ_enter(){ runvms=(${${(M)${(f)"$(vzlist -H -a -o veid,status,hostname)"}:#[[:blank:]]##[[:digit:]]*running*}/(#b)[[:blank:]]##([[:digit:]]##)[[:blank:]]##[[:alpha:]]##[[:blank:]]##/$match[1]:}) _arguments -s '1:veid:(($runvms))' } |
Au fur et à mesure, le script sera mis à jour.
OpenRC + Baselayout 2
Voici un projet initié par Roy Marples alias UberLord qui a fait un excellent travail avec ce script de RC programmé en C et “Unix-Compliant”. Grace à lui, votre machine démarre de 1 à 3 fois plus vite selon la configuration. Pour pouvoir installer OpenRC, il faut en premier lieu installer “layman”, et installer “git”, pour enfin ajouter l’overlay de openrc comme ceci : “layman -a openrc”. Ensuite il ne vous reste plus qu’a faire “emerge -uDNav openrc” et vous voila parti pour 5 à 6 minutes d’installation grand maximum, il faudra juste penser que certains des fichiers de configuration sont “useless” tel que le bon vieux “/etc/modules.autoload/kernel-2.x” qui est remplacé par “/etc/conf.d/modules”. OpenRC ne vous manquera pas de le faire remarquer à la fin de l’installation dans les explications “post-install”. Merci Roy pour ce travail très abouti ! Blog de monsieur
I Like Zsh
The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh can be thought of as an extended bourne shell with a large number of improvements, including some of the most useful features of bash, ksh, and tcsh. The first version of zsh was written by Paul Falstad in 1990 when he was a student at Princeton University. The name zsh derives from Zhong Shao, then a teaching assistant at Princeton University. Paul Falstad thought that Shao’s login name, “zsh”, was a good name for a shell. Features of note include: Programmable command line completion that can help the user type both options and arguments for most used commands, with out-of-the-box support for several hundred commands Sharing of command history among all running shells Extended file globbing allows file specification without needing to run…