forked from ungleich-public/cdist
		
	allow hostnamectl to fail silently
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								0114001627
							
						
					
				
			
			
				commit
				
					
						3c3b29f710
					
				
			
		
					 1 changed files with 19 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#!/bin/sh -e
 | 
			
		||||
#
 | 
			
		||||
# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
			
		||||
# 2014-2017 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
			
		||||
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
| 
						 | 
				
			
			@ -56,15 +56,13 @@ esac
 | 
			
		|||
#
 | 
			
		||||
echo changed >> "$__messages_out"
 | 
			
		||||
 | 
			
		||||
if [ "$has_hostnamectl" ]; then
 | 
			
		||||
    echo "hostnamectl set-hostname '$name_should'"
 | 
			
		||||
else
 | 
			
		||||
# Use the good old way to set the hostname even on machines running systemd.
 | 
			
		||||
case "$os" in
 | 
			
		||||
        archlinux|debian|ubuntu|devuan)
 | 
			
		||||
            echo "hostname '$name_should'"
 | 
			
		||||
    archlinux|debian|ubuntu|devuan|centos)
 | 
			
		||||
        echo "printf '%s\n' '$name_should' > /etc/hostname"
 | 
			
		||||
        echo "hostname -F /etc/hostname"
 | 
			
		||||
    ;;
 | 
			
		||||
        centos|openbsd)
 | 
			
		||||
    openbsd)
 | 
			
		||||
        echo "hostname '$name_should'"
 | 
			
		||||
    ;;
 | 
			
		||||
    suse)
 | 
			
		||||
| 
						 | 
				
			
			@ -72,4 +70,9 @@ else
 | 
			
		|||
        echo "printf '%s\n' '$name_should' > /etc/HOSTNAME"
 | 
			
		||||
    ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
if [ "$has_hostnamectl" ]; then
 | 
			
		||||
    # Allow hostnamectl set-hostname to fail silently.
 | 
			
		||||
    # Who the fuck invented a tool that needs dbus to set the hostname anyway ...
 | 
			
		||||
    echo "hostnamectl set-hostname '$name_should' || true"
 | 
			
		||||
fi
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue