forked from ungleich-public/cdist
		
	[__hostname] Lint
This commit is contained in:
		
					parent
					
						
							
								cbb108d61c
							
						
					
				
			
			
				commit
				
					
						6e1a105c22
					
				
			
		
					 2 changed files with 12 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -29,7 +29,8 @@ has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
 | 
			
		|||
if [ -f "$__object/parameter/name" ]; then
 | 
			
		||||
    name_should="$(cat "$__object/parameter/name")"
 | 
			
		||||
else
 | 
			
		||||
    case $os in
 | 
			
		||||
    case $os
 | 
			
		||||
    in
 | 
			
		||||
        # RedHat-derivatives and BSDs
 | 
			
		||||
        centos|fedora|redhat|scientific|freebsd|netbsd|openbsd)
 | 
			
		||||
            # Hostname is FQDN
 | 
			
		||||
| 
						 | 
				
			
			@ -45,14 +46,16 @@ fi
 | 
			
		|||
################################################################################
 | 
			
		||||
# Check if the hostname is already correct
 | 
			
		||||
#
 | 
			
		||||
if [ "$name_running" = "$name_should" ] && [ ! "$name_config" -o "$name_config" = "$name_should" ]; then
 | 
			
		||||
if [ "$name_running" = "$name_should" ] \
 | 
			
		||||
  && [ -z "$name_config" -o "$name_config" = "$name_should" ]
 | 
			
		||||
then
 | 
			
		||||
    exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
################################################################################
 | 
			
		||||
# Setup hostname
 | 
			
		||||
#
 | 
			
		||||
echo changed >> "$__messages_out"
 | 
			
		||||
echo 'changed' >> "$__messages_out"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# First try to set the hostname using hostnamectl, if available.
 | 
			
		||||
| 
						 | 
				
			
			@ -69,7 +72,8 @@ EOF
 | 
			
		|||
fi
 | 
			
		||||
 | 
			
		||||
# Use the good old way to set the hostname. Also if hostnamectl fails.
 | 
			
		||||
case $os in
 | 
			
		||||
case $os
 | 
			
		||||
in
 | 
			
		||||
    archlinux|debian|ubuntu|devuan|coreos|alpine)
 | 
			
		||||
        printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n"
 | 
			
		||||
        echo "hostname -F /etc/hostname"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,8 @@ os=$(cat "$__global/explorer/os")
 | 
			
		|||
if [ -f "$__object/parameter/name" ]; then
 | 
			
		||||
    name_should="$(cat "$__object/parameter/name")"
 | 
			
		||||
else
 | 
			
		||||
    case $os in
 | 
			
		||||
    case $os
 | 
			
		||||
    in
 | 
			
		||||
        # RedHat-derivatives and BSDs
 | 
			
		||||
        centos|fedora|redhat|scientific|freebsd|netbsd|openbsd)
 | 
			
		||||
            # Hostname is FQDN
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +45,8 @@ not_supported() {
 | 
			
		|||
   exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
case "$os" in
 | 
			
		||||
case $os
 | 
			
		||||
in
 | 
			
		||||
    archlinux|debian|suse|ubuntu|devuan|coreos|alpine|macosx)
 | 
			
		||||
        # handled in gencode-remote
 | 
			
		||||
        :
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue