forked from ungleich-public/cdist
		
	[__hostname] Only write to distro specific file when hostnamectl is missing
This commit is contained in:
		
					parent
					
						
							
								c11e757dfa
							
						
					
				
			
			
				commit
				
					
						30c7d153e8
					
				
			
		
					 2 changed files with 26 additions and 11 deletions
				
			
		| 
						 | 
					@ -78,6 +78,11 @@ in
 | 
				
			||||||
        echo "printf '%s\\n' '$name_should' > /etc/hostname"
 | 
					        echo "printf '%s\\n' '$name_should' > /etc/hostname"
 | 
				
			||||||
        echo "hostname -F /etc/hostname"
 | 
					        echo "hostname -F /etc/hostname"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
 | 
					    gentoo)
 | 
				
			||||||
 | 
					        # NOTE: Writing the hostname to file is done in the manifest for OpenRC.
 | 
				
			||||||
 | 
					        #       For systemd hostnamectl should take care of that.
 | 
				
			||||||
 | 
					        echo "hostname '$name_should'"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
    macosx)
 | 
					    macosx)
 | 
				
			||||||
        echo "scutil --set HostName '$name_should'"
 | 
					        echo "scutil --set HostName '$name_should'"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
| 
						 | 
					@ -87,7 +92,7 @@ in
 | 
				
			||||||
        echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME"
 | 
					        echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME"
 | 
				
			||||||
        echo 'hostname -F /etc/HOSTNAME'
 | 
					        echo 'hostname -F /etc/HOSTNAME'
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    centos|fedora|freebsd|gentoo|netbsd|openbsd|redhat|scientific)
 | 
					    centos|fedora|freebsd|netbsd|openbsd|redhat|scientific)
 | 
				
			||||||
        # NOTE: Writing the hostname to file is done in the manifest.
 | 
					        # NOTE: Writing the hostname to file is done in the manifest.
 | 
				
			||||||
        echo "hostname '$name_should'"
 | 
					        echo "hostname '$name_should'"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,18 +52,28 @@ in
 | 
				
			||||||
        :
 | 
					        :
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    centos|fedora|redhat|scientific)
 | 
					    centos|fedora|redhat|scientific)
 | 
				
			||||||
        __key_value sysconfig-hostname \
 | 
					        if test -z "$(cat "$__object/explorer/has_hostnamectl")"
 | 
				
			||||||
            --file /etc/sysconfig/network \
 | 
					        then
 | 
				
			||||||
            --delimiter '=' --exact_delimiter \
 | 
					            # Only write to /etc/sysconfig/network on non-systemd versions.
 | 
				
			||||||
            --key HOSTNAME \
 | 
					            # On systemd-based versions this entry is ignored.
 | 
				
			||||||
            --value "\"$name_should\""
 | 
					            __key_value sysconfig-hostname \
 | 
				
			||||||
 | 
					                --file /etc/sysconfig/network \
 | 
				
			||||||
 | 
					                --delimiter '=' --exact_delimiter \
 | 
				
			||||||
 | 
					                --key HOSTNAME \
 | 
				
			||||||
 | 
					                --value "\"$name_should\""
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    gentoo)
 | 
					    gentoo)
 | 
				
			||||||
        __key_value confd-hostname \
 | 
					        if test -z "$(cat "$__object/explorer/has_hostnamectl")"
 | 
				
			||||||
            --file /etc/conf.d/hostname \
 | 
					        then
 | 
				
			||||||
            --delimiter '=' --exact_delimiter \
 | 
					            # Only write to /etc/conf.d/hostname on OpenRC-based installations.
 | 
				
			||||||
            --key 'hostname' \
 | 
					            # On systemd use hostnamectl(1) in gencode-remote.
 | 
				
			||||||
            --value "\"$name_should\""
 | 
					            __key_value confd-hostname \
 | 
				
			||||||
 | 
					                --file /etc/conf.d/hostname \
 | 
				
			||||||
 | 
					                --delimiter '=' --exact_delimiter \
 | 
				
			||||||
 | 
					                --key 'hostname' \
 | 
				
			||||||
 | 
					                --value "\"$name_should\""
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    freebsd)
 | 
					    freebsd)
 | 
				
			||||||
        __key_value rcconf-hostname \
 | 
					        __key_value rcconf-hostname \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue