forked from ungleich-public/cdist
		
	[__hostname] Support openSUSE and replace printf with echo
This commit is contained in:
		
					parent
					
						
							
								da1d70e16a
							
						
					
				
			
			
				commit
				
					
						064e992a7a
					
				
			
		
					 2 changed files with 13 additions and 11 deletions
				
			
		| 
						 | 
					@ -31,12 +31,9 @@ fi
 | 
				
			||||||
# Fall back to alternative OS-specific approaches.
 | 
					# Fall back to alternative OS-specific approaches.
 | 
				
			||||||
case $("$__explorer/os")
 | 
					case $("$__explorer/os")
 | 
				
			||||||
in
 | 
					in
 | 
				
			||||||
	alpine|archlinux|coreos|debian|devuan|suse|ubuntu)
 | 
						alpine|archlinux|coreos|debian|devuan|ubuntu)
 | 
				
			||||||
		[ -f /etc/hostname ] && cat /etc/hostname
 | 
							[ -f /etc/hostname ] && cat /etc/hostname
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
	suse)
 | 
					 | 
				
			||||||
		[ -f /etc/HOSTNAME ] && cat /etc/HOSTNAME
 | 
					 | 
				
			||||||
		;;
 | 
					 | 
				
			||||||
	centos|fedora|redhat|scientific)
 | 
						centos|fedora|redhat|scientific)
 | 
				
			||||||
		[ -f /etc/sysconfig/network ] \
 | 
							[ -f /etc/sysconfig/network ] \
 | 
				
			||||||
			&& (. /etc/sysconfig/network && echo "$HOSTNAME")
 | 
								&& (. /etc/sysconfig/network && echo "$HOSTNAME")
 | 
				
			||||||
| 
						 | 
					@ -44,6 +41,9 @@ in
 | 
				
			||||||
	freebsd)
 | 
						freebsd)
 | 
				
			||||||
		(. /etc/rc.conf && echo "$hostname")
 | 
							(. /etc/rc.conf && echo "$hostname")
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
 | 
						macosx)
 | 
				
			||||||
 | 
							scutil --get HostName 2>/dev/null
 | 
				
			||||||
 | 
							;;
 | 
				
			||||||
	netbsd)
 | 
						netbsd)
 | 
				
			||||||
		if grep -q '^hostname=' /etc/rc.conf
 | 
							if grep -q '^hostname=' /etc/rc.conf
 | 
				
			||||||
		then
 | 
							then
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,7 @@ in
 | 
				
			||||||
	openbsd)
 | 
						openbsd)
 | 
				
			||||||
		cat /etc/myname
 | 
							cat /etc/myname
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
	macosx)
 | 
						suse)
 | 
				
			||||||
		scutil --get HostName 2>/dev/null
 | 
							cat /etc/HOSTNAME 2>/dev/null
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,20 +75,22 @@ fi
 | 
				
			||||||
case $os
 | 
					case $os
 | 
				
			||||||
in
 | 
					in
 | 
				
			||||||
    archlinux|debian|ubuntu|devuan|coreos|alpine)
 | 
					    archlinux|debian|ubuntu|devuan|coreos|alpine)
 | 
				
			||||||
        printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n"
 | 
					        echo "printf '%s\\n' '$name_should' > /etc/hostname"
 | 
				
			||||||
        echo "hostname -F /etc/hostname"
 | 
					        echo "hostname -F /etc/hostname"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    centos|fedora|redhat|scientific|freebsd|openbsd)
 | 
					    centos|fedora|redhat|scientific|freebsd|openbsd)
 | 
				
			||||||
        # 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'"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    suse)
 | 
					 | 
				
			||||||
        echo "hostname '$name_should'"
 | 
					 | 
				
			||||||
        printf "printf '%%s\\\\n' '$name_should' > /etc/HOSTNAME\\n"
 | 
					 | 
				
			||||||
    ;;
 | 
					 | 
				
			||||||
    macosx)
 | 
					    macosx)
 | 
				
			||||||
        echo "scutil --set HostName '$name_should'"
 | 
					        echo "scutil --set HostName '$name_should'"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
 | 
					    suse)
 | 
				
			||||||
 | 
					        # We write into /etc/HOSTNAME for backwards-compatibility.  Modern SuSE
 | 
				
			||||||
 | 
					        # has hostnamectl anyway and symlinks /etc/HOSTNAME to /etc/hostname.
 | 
				
			||||||
 | 
					        echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME"
 | 
				
			||||||
 | 
					        echo 'hostname -F /etc/HOSTNAME'
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
    *)
 | 
					    *)
 | 
				
			||||||
        echo "echo 'Unsupported OS: $os' >&2; exit 1"
 | 
					        echo "echo 'Unsupported OS: $os' >&2; exit 1"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue