diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-08-10 15:48:20 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-08-10 15:48:20 -0400 |
commit | c73db02271a67e9ceb42115dde6be997ec4b89ef (patch) | |
tree | 7bf9b14a3e741cfa37a2f93be964538b959964a5 /src/grp-hostname | |
parent | ae3660f9eb1618b0cc54bf5dffcc5d13ced8922e (diff) |
split up grp-{hostname,locale}, grp-resolve/systemd-resolve{,d}; shell completion
Diffstat (limited to 'src/grp-hostname')
11 files changed, 255 insertions, 52 deletions
diff --git a/src/grp-hostname/Makefile b/src/grp-hostname/Makefile index 911188454c..319c1d2c8e 100644 --- a/src/grp-hostname/Makefile +++ b/src/grp-hostname/Makefile @@ -23,57 +23,6 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk -ifneq ($(ENABLE_HOSTNAMED),) -systemd_hostnamed_SOURCES = \ - src/hostname/hostnamed.c - -systemd_hostnamed_LDADD = \ - libshared.la - -rootlibexec_PROGRAMS += \ - systemd-hostnamed - -nodist_systemunit_DATA += \ - units/systemd-hostnamed.service - -dist_systemunit_DATA_busnames += \ - units/org.freedesktop.hostname1.busname - -dist_dbuspolicy_DATA += \ - src/hostname/org.freedesktop.hostname1.conf - -dist_dbussystemservice_DATA += \ - src/hostname/org.freedesktop.hostname1.service - -polkitpolicy_files += \ - src/hostname/org.freedesktop.hostname1.policy - -SYSTEM_UNIT_ALIASES += \ - systemd-hostnamed.service dbus-org.freedesktop.hostname1.service - -BUSNAMES_TARGET_WANTS += \ - org.freedesktop.hostname1.busname - -hostnamectl_SOURCES = \ - src/hostname/hostnamectl.c - -hostnamectl_LDADD = \ - libshared.la - -bin_PROGRAMS += \ - hostnamectl - -dist_bashcompletion_data += \ - shell-completion/bash/hostnamectl - -dist_zshcompletion_data += \ - shell-completion/zsh/_hostnamectl -endif # ENABLE_HOSTNAMED - -polkitpolicy_in_files += \ - src/hostname/org.freedesktop.hostname1.policy.in - -EXTRA_DIST += \ - units/systemd-hostnamed.service.in +nested.subdirs += systemd-hostnamed hostnamectl include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/grp-hostname/hostnamectl/Makefile b/src/grp-hostname/hostnamectl/Makefile new file mode 100644 index 0000000000..f684bde523 --- /dev/null +++ b/src/grp-hostname/hostnamectl/Makefile @@ -0,0 +1,45 @@ +# -*- Mode: makefile; indent-tabs-mode: t -*- +# +# This file is part of systemd. +# +# Copyright 2010-2012 Lennart Poettering +# Copyright 2010-2012 Kay Sievers +# Copyright 2013 Zbigniew Jędrzejewski-Szmek +# Copyright 2013 David Strauss +# Copyright 2016 Luke Shumaker +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with systemd; If not, see <http://www.gnu.org/licenses/>. +include $(dir $(lastword $(MAKEFILE_LIST)))/../../../config.mk +include $(topsrcdir)/build-aux/Makefile.head.mk + +ifneq ($(ENABLE_HOSTNAMED),) + +hostnamectl_SOURCES = \ + src/hostname/hostnamectl.c + +hostnamectl_LDADD = \ + libshared.la + +bin_PROGRAMS += \ + hostnamectl + +dist_bashcompletion_data += \ + shell-completion/bash/hostnamectl + +dist_zshcompletion_data += \ + shell-completion/zsh/_hostnamectl + +endif + +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/grp-hostname/hostnamectl.c b/src/grp-hostname/hostnamectl/hostnamectl.c index 8a24813934..8a24813934 100644 --- a/src/grp-hostname/hostnamectl.c +++ b/src/grp-hostname/hostnamectl/hostnamectl.c diff --git a/src/grp-hostname/hostnamectl/hostnamectl.completion.bash b/src/grp-hostname/hostnamectl/hostnamectl.completion.bash new file mode 100644 index 0000000000..6a252188ea --- /dev/null +++ b/src/grp-hostname/hostnamectl/hostnamectl.completion.bash @@ -0,0 +1,64 @@ +# hostnamectl(1) completion -*- shell-script -*- +# +# This file is part of systemd. +# +# Copyright 2010 Ran Benita +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with systemd; If not, see <http://www.gnu.org/licenses/>. + +__contains_word () { + local w word=$1; shift + for w in "$@"; do + [[ $w = "$word" ]] && return + done +} + +_hostnamectl() { + local i verb comps + local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} + local OPTS='-h --help --version --transient --static --pretty + --no-ask-password -H --host --machine' + + if [[ $cur = -* ]]; then + COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) + return 0 + fi + + local -A VERBS=( + [STANDALONE]='status' + [ICONS]='set-icon-name' + [NAME]='set-hostname set-deployment set-location' + [CHASSIS]='set-chassis' + ) + + for ((i=0; i < COMP_CWORD; i++)); do + if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then + verb=${COMP_WORDS[i]} + break + fi + done + + if [[ -z $verb ]]; then + comps=${VERBS[*]} + elif __contains_word "$verb" ${VERBS[CHASSIS]}; then + comps='desktop laptop server tablet handset watch embedded vm container' + elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[ICONS]} ${VERBS[NAME]}; then + comps='' + fi + + COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + return 0 +} + +complete -F _hostnamectl hostnamectl diff --git a/src/grp-hostname/hostnamectl/hostnamectl.completion.zsh b/src/grp-hostname/hostnamectl/hostnamectl.completion.zsh new file mode 100644 index 0000000000..7528e0649d --- /dev/null +++ b/src/grp-hostname/hostnamectl/hostnamectl.completion.zsh @@ -0,0 +1,80 @@ +#compdef hostnamectl + +_hostnamectl_set-hostname() { + if (( CURRENT <= 3 )); then + _message "new hostname" + else + _message "no more options" + fi +} + +_hostnamectl_set-icon-name() { + if (( CURRENT <= 3 )); then + _message "new icon name" + else + _message "no more options" + fi +} + +_hostnamectl_set-chassis() { + if (( CURRENT <= 3 )); then + _chassis=( desktop laptop server tablet handset watch embedded vm container ) + _describe chassis _chassis + else + _message "no more options" + fi +} + +_hostnamectl_set-deployment() { + if (( CURRENT <= 3 )); then + _message "new environment" + else + _message "no more options" + fi +} + +_hostnamectl_set-location() { + if (( CURRENT <= 3 )); then + _message "new location" + else + _message "no more options" + fi +} + +_hostnamectl_command() { + local -a _hostnamectl_cmds + _hostnamectl_cmds=( + "status:Show current hostname settings" + "set-hostname:Set system hostname" + "set-icon-name:Set icon name for host" + "set-chassis:Set chassis type for host" + "set-deployment:Set deployment environment for host" + "set-location:Set location for host" + ) + if (( CURRENT == 1 )); then + _describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@" + else + local curcontext="$curcontext" + cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}" + if (( $#cmd )); then + if [[ $cmd == status ]]; then + _message "no options" + else + _hostnamectl_$cmd + fi + else + _message "unknown hostnamectl command: $words[1]" + fi + fi +} + +_arguments -s \ + {-h,--help}'[Show this help]' \ + '--version[Show package version]' \ + '--transient[Only set transient hostname]' \ + '--static[Only set static hostname]' \ + '--pretty[Only set pretty hostname]' \ + '--no-ask-password[Do not prompt for password]' \ + {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ + {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ + '*::hostnamectl commands:_hostnamectl_command' diff --git a/src/grp-hostname/.gitignore b/src/grp-hostname/systemd-hostnamed/.gitignore index 1ff281b231..1ff281b231 100644 --- a/src/grp-hostname/.gitignore +++ b/src/grp-hostname/systemd-hostnamed/.gitignore diff --git a/src/grp-hostname/systemd-hostnamed/Makefile b/src/grp-hostname/systemd-hostnamed/Makefile new file mode 100644 index 0000000000..171bce55a4 --- /dev/null +++ b/src/grp-hostname/systemd-hostnamed/Makefile @@ -0,0 +1,65 @@ +# -*- Mode: makefile; indent-tabs-mode: t -*- +# +# This file is part of systemd. +# +# Copyright 2010-2012 Lennart Poettering +# Copyright 2010-2012 Kay Sievers +# Copyright 2013 Zbigniew Jędrzejewski-Szmek +# Copyright 2013 David Strauss +# Copyright 2016 Luke Shumaker +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with systemd; If not, see <http://www.gnu.org/licenses/>. +include $(dir $(lastword $(MAKEFILE_LIST)))/../../../config.mk +include $(topsrcdir)/build-aux/Makefile.head.mk + +ifneq ($(ENABLE_HOSTNAMED),) +systemd_hostnamed_SOURCES = \ + src/hostname/hostnamed.c + +systemd_hostnamed_LDADD = \ + libshared.la + +rootlibexec_PROGRAMS += \ + systemd-hostnamed + +nodist_systemunit_DATA += \ + units/systemd-hostnamed.service + +dist_systemunit_DATA_busnames += \ + units/org.freedesktop.hostname1.busname + +dist_dbuspolicy_DATA += \ + src/hostname/org.freedesktop.hostname1.conf + +dist_dbussystemservice_DATA += \ + src/hostname/org.freedesktop.hostname1.service + +polkitpolicy_files += \ + src/hostname/org.freedesktop.hostname1.policy + +SYSTEM_UNIT_ALIASES += \ + systemd-hostnamed.service dbus-org.freedesktop.hostname1.service + +BUSNAMES_TARGET_WANTS += \ + org.freedesktop.hostname1.busname + +endif # ENABLE_HOSTNAMED + +polkitpolicy_in_files += \ + src/hostname/org.freedesktop.hostname1.policy.in + +EXTRA_DIST += \ + units/systemd-hostnamed.service.in + +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/grp-hostname/hostnamed.c b/src/grp-hostname/systemd-hostnamed/hostnamed.c index 22eabc469b..22eabc469b 100644 --- a/src/grp-hostname/hostnamed.c +++ b/src/grp-hostname/systemd-hostnamed/hostnamed.c diff --git a/src/grp-hostname/org.freedesktop.hostname1.conf b/src/grp-hostname/systemd-hostnamed/org.freedesktop.hostname1.conf index 46b4aadc83..46b4aadc83 100644 --- a/src/grp-hostname/org.freedesktop.hostname1.conf +++ b/src/grp-hostname/systemd-hostnamed/org.freedesktop.hostname1.conf diff --git a/src/grp-hostname/org.freedesktop.hostname1.policy.in b/src/grp-hostname/systemd-hostnamed/org.freedesktop.hostname1.policy.in index c32c1d4fda..c32c1d4fda 100644 --- a/src/grp-hostname/org.freedesktop.hostname1.policy.in +++ b/src/grp-hostname/systemd-hostnamed/org.freedesktop.hostname1.policy.in diff --git a/src/grp-hostname/org.freedesktop.hostname1.service b/src/grp-hostname/systemd-hostnamed/org.freedesktop.hostname1.service index 6041ed60ca..6041ed60ca 100644 --- a/src/grp-hostname/org.freedesktop.hostname1.service +++ b/src/grp-hostname/systemd-hostnamed/org.freedesktop.hostname1.service |