Merge branch 'feature/__mount' of git://github.com/asteven/cdist
This commit is contained in:
		
				commit
				
					
						f336bcb6fc
					
				
			
		
					 10 changed files with 212 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								cdist/conf/type/__mount/explorer/mounted
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										27
									
								
								cdist/conf/type/__mount/explorer/mounted
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
#!/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/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
path="$(cat "$__object/parameter/path" 2>/dev/null || echo "/$__object_id")"
 | 
			
		||||
 | 
			
		||||
if mountpoint -q "$path"; then
 | 
			
		||||
   echo yes
 | 
			
		||||
else
 | 
			
		||||
   echo no
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										51
									
								
								cdist/conf/type/__mount/gencode-remote
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										51
									
								
								cdist/conf/type/__mount/gencode-remote
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,51 @@
 | 
			
		|||
#!/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/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
path="$(cat "$__object/parameter/path" 2>/dev/null || echo "/$__object_id")"
 | 
			
		||||
state_should="$(cat "$__object/parameter/state")"
 | 
			
		||||
state_is="$(grep -q -x yes "$__object/explorer/mounted" && echo present || echo absent)"
 | 
			
		||||
 | 
			
		||||
if [ "$state_should" = "$state_is" ]; then
 | 
			
		||||
   # nothing to do
 | 
			
		||||
   exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
case "$state_should" in
 | 
			
		||||
   present)
 | 
			
		||||
      if [ -f "$__object/parameter/nofstab" ]; then
 | 
			
		||||
         # mount manually
 | 
			
		||||
         printf 'mount'
 | 
			
		||||
         if [ -f "$__object/parameter/type" ]; then
 | 
			
		||||
            printf ' -t %s' "$(cat "$__object/parameter/type")"
 | 
			
		||||
         fi
 | 
			
		||||
         if [ -f "$__object/parameter/options" ]; then
 | 
			
		||||
            printf ' -o %s' "$(cat "$__object/parameter/options")"
 | 
			
		||||
         fi
 | 
			
		||||
         printf ' %s' "$(cat "$__object/parameter/device")"
 | 
			
		||||
         printf " %s\n" "$path"
 | 
			
		||||
      else
 | 
			
		||||
         # mount using existing fstab entry
 | 
			
		||||
         printf 'mount "%s"\n' "$path"
 | 
			
		||||
      fi
 | 
			
		||||
   ;;
 | 
			
		||||
   absent)
 | 
			
		||||
      printf 'umount "%s"\n' "$path"
 | 
			
		||||
   ;;
 | 
			
		||||
esac
 | 
			
		||||
							
								
								
									
										80
									
								
								cdist/conf/type/__mount/man.text
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								cdist/conf/type/__mount/man.text
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,80 @@
 | 
			
		|||
cdist-type__mount(7)
 | 
			
		||||
====================
 | 
			
		||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
NAME
 | 
			
		||||
----
 | 
			
		||||
cdist-type__mount - manage filesystem mounts
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DESCRIPTION
 | 
			
		||||
-----------
 | 
			
		||||
Manage filesystem mounts either via /etc/fstab or manually.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
REQUIRED PARAMETERS
 | 
			
		||||
-------------------
 | 
			
		||||
None.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
OPTIONAL PARAMETERS
 | 
			
		||||
-------------------
 | 
			
		||||
device::
 | 
			
		||||
   device to mount at path, defaults to 'none'. see mount(8)
 | 
			
		||||
 | 
			
		||||
dump::
 | 
			
		||||
   value for the dump field in fstab. see fstab(5)
 | 
			
		||||
   defaults to 0.
 | 
			
		||||
 | 
			
		||||
options::
 | 
			
		||||
   comma separated string of options, see mount(8)
 | 
			
		||||
 | 
			
		||||
pass::
 | 
			
		||||
   value for the pass field in fstab. see fstab(5)
 | 
			
		||||
   defaults to 0.
 | 
			
		||||
 | 
			
		||||
path::
 | 
			
		||||
   mount point where to mount the device, see mount(8).
 | 
			
		||||
   Defaults to __object_id
 | 
			
		||||
 | 
			
		||||
state::
 | 
			
		||||
   either present or absent. Defaults to present.
 | 
			
		||||
 | 
			
		||||
type::
 | 
			
		||||
   vfstype, see mount(8)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
BOOLEAN PARAMETERS
 | 
			
		||||
------------------
 | 
			
		||||
nofstab::
 | 
			
		||||
   do not manage an entry in /etc/fstab
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
EXAMPLES
 | 
			
		||||
--------
 | 
			
		||||
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
__mount /some/dir \
 | 
			
		||||
   --device /dev/sdc3 \
 | 
			
		||||
   --type xfs \
 | 
			
		||||
   --options "defaults,ro"
 | 
			
		||||
   --dump 0 \
 | 
			
		||||
   --pass 1
 | 
			
		||||
 | 
			
		||||
__mount /var/lib/one \
 | 
			
		||||
   --device mfsmount \
 | 
			
		||||
   --type fuse \
 | 
			
		||||
   --options "mfsmaster=mfsmaster.domain.tld,mfssubfolder=/one,nonempty,_netdev"
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SEE ALSO
 | 
			
		||||
--------
 | 
			
		||||
- cdist-type(7)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
COPYING
 | 
			
		||||
-------
 | 
			
		||||
Copyright \(C) 2014 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/__mount/manifest
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										42
									
								
								cdist/conf/type/__mount/manifest
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
#!/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/>.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
path="$(cat "$__object/parameter/path" 2>/dev/null || echo "/$__object_id")"
 | 
			
		||||
state="$(cat "$__object/parameter/state")"
 | 
			
		||||
 | 
			
		||||
if [ ! -f "$__object/parameter/nofstab" ]; then
 | 
			
		||||
   # Generate an entry for /etc/fstab
 | 
			
		||||
   (
 | 
			
		||||
printf "%s" "$(cat "$__object/parameter/device")"
 | 
			
		||||
printf " %s" "$path"
 | 
			
		||||
type="$(cat "$__object/parameter/type" || echo "auto")"
 | 
			
		||||
printf " %s" "$type"
 | 
			
		||||
options="$(cat "$__object/parameter/options" || echo "defaults")"
 | 
			
		||||
printf " %s" "$options"
 | 
			
		||||
printf " %s" "$(cat "$__object/parameter/dump")"
 | 
			
		||||
printf " %s\n" "$(cat "$__object/parameter/pass")"
 | 
			
		||||
) | \
 | 
			
		||||
__block "$__object_name" \
 | 
			
		||||
   --file "/etc/fstab" \
 | 
			
		||||
   --prefix "#cdist:$__object_name" \
 | 
			
		||||
   --suffix "#/cdist:$__object_name" \
 | 
			
		||||
   --state "$state" \
 | 
			
		||||
   --text -
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__mount/parameter/boolean
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__mount/parameter/boolean
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
nofstab
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/device
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/device
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
none
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/dump
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/dump
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
0
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/pass
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/pass
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
0
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/state
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__mount/parameter/default/state
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
present
 | 
			
		||||
							
								
								
									
										7
									
								
								cdist/conf/type/__mount/parameter/optional
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								cdist/conf/type/__mount/parameter/optional
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
device
 | 
			
		||||
dump
 | 
			
		||||
options
 | 
			
		||||
pass
 | 
			
		||||
path
 | 
			
		||||
state
 | 
			
		||||
type
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue