forked from ungleich-public/cdist
		
	import __hostname - Thanks, Steven!
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
		
					parent
					
						
							
								13001924c0
							
						
					
				
			
			
				commit
				
					
						5279b7239c
					
				
			
		
					 5 changed files with 123 additions and 0 deletions
				
			
		
							
								
								
									
										33
									
								
								cdist/conf/type/__hostname/gencode-remote
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								cdist/conf/type/__hostname/gencode-remote
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
#
 | 
			
		||||
# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
#
 | 
			
		||||
# cdist is free software: you can redistribute it and/or modify
 | 
			
		||||
# it under the terms of the GNU General Public License as published by
 | 
			
		||||
# the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
# (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
# cdist 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 General Public License
 | 
			
		||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
name="$(cat "$__object/parameter/name")"
 | 
			
		||||
os=$(cat "$__global/explorer/os")
 | 
			
		||||
 | 
			
		||||
echo "printf '%s\n' '$name' > /etc/hostname"
 | 
			
		||||
 | 
			
		||||
case "$os" in
 | 
			
		||||
   debian|ubuntu)
 | 
			
		||||
      echo "hostname \"$name\""
 | 
			
		||||
   ;;
 | 
			
		||||
   archlinux)
 | 
			
		||||
      echo "hostnamectl set-hostname \"$name\""
 | 
			
		||||
   ;;
 | 
			
		||||
esac
 | 
			
		||||
							
								
								
									
										47
									
								
								cdist/conf/type/__hostname/man.text
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								cdist/conf/type/__hostname/man.text
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
cdist-type__hostname(7)
 | 
			
		||||
=======================
 | 
			
		||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
NAME
 | 
			
		||||
----
 | 
			
		||||
cdist-type__hostname - set the hostname
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DESCRIPTION
 | 
			
		||||
-----------
 | 
			
		||||
Set's the hostname on various operating systems.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
REQUIRED PARAMETERS
 | 
			
		||||
-------------------
 | 
			
		||||
None.
 | 
			
		||||
 | 
			
		||||
OPTIONAL PARAMETERS
 | 
			
		||||
-------------------
 | 
			
		||||
name::
 | 
			
		||||
   The hostname to set. Defaults to the first segment of __target_host 
 | 
			
		||||
   (${__target_host%%.*})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
EXAMPLES
 | 
			
		||||
--------
 | 
			
		||||
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
# take hostname from __target_host
 | 
			
		||||
__hostname
 | 
			
		||||
 | 
			
		||||
# set hostname explicitly
 | 
			
		||||
__hostname --name some-static-hostname
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SEE ALSO
 | 
			
		||||
--------
 | 
			
		||||
- cdist-type(7)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
COPYING
 | 
			
		||||
-------
 | 
			
		||||
Copyright \(C) 2012 Steven Armstrong. Free use of this software is
 | 
			
		||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
 | 
			
		||||
							
								
								
									
										42
									
								
								cdist/conf/type/__hostname/manifest
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										42
									
								
								cdist/conf/type/__hostname/manifest
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
#
 | 
			
		||||
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
#
 | 
			
		||||
# cdist is free software: you can redistribute it and/or modify
 | 
			
		||||
# it under the terms of the GNU General Public License as published by
 | 
			
		||||
# the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
# (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
# cdist 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 General Public License
 | 
			
		||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
# set defaults
 | 
			
		||||
name="$(cat "$__object/parameter/name" 2>/dev/null \
 | 
			
		||||
   || echo "${__target_host%%.*}" | tee "$__object/parameter/name")"
 | 
			
		||||
 | 
			
		||||
os=$(cat "$__global/explorer/os")
 | 
			
		||||
 | 
			
		||||
not_supported() {
 | 
			
		||||
   echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
 | 
			
		||||
   echo "Please contribute an implementation for it if you can." >&2
 | 
			
		||||
   exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
case "$os" in
 | 
			
		||||
   archlinux|debian|ubuntu)
 | 
			
		||||
      # handled in gencode-remote
 | 
			
		||||
      # FIXED: hostname setup in archlinuz via rc.local ist outdated
 | 
			
		||||
      :
 | 
			
		||||
   ;;
 | 
			
		||||
   *)
 | 
			
		||||
      not_supported
 | 
			
		||||
   ;;
 | 
			
		||||
esac
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__hostname/parameter/optional
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__hostname/parameter/optional
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
name
 | 
			
		||||
							
								
								
									
										0
									
								
								cdist/conf/type/__hostname/singleton
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								cdist/conf/type/__hostname/singleton
									
										
									
									
									
										Normal file
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue