forked from ungleich-public/cdist
		
	Created deleteJail function. Ready to begin debugging.
This commit is contained in:
		
					parent
					
						
							
								18c0e947aa
							
						
					
				
			
			
				commit
				
					
						446f497c4c
					
				
			
		
					 1 changed files with 23 additions and 4 deletions
				
			
		| 
						 | 
					@ -109,13 +109,31 @@ startJail() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
deleteJail() {
 | 
					deleteJail() {
 | 
				
			||||||
# If the jail's mountpoints are mounted, unmount them
 | 
					 | 
				
			||||||
# Remove the jail's rw mountpoints
 | 
					# Remove the jail's rw mountpoints
 | 
				
			||||||
# Remove the jail's ro mountpoint
 | 
					   echo "rm -rf /usr/jail/rw/${name}"
 | 
				
			||||||
 | 
					# Remove the jail's fstab
 | 
				
			||||||
 | 
					   echo "rm -f /etc/fstab.${name}"
 | 
				
			||||||
# Remove the jail directory
 | 
					# Remove the jail directory
 | 
				
			||||||
# If the jail's devfs rules are custom (!="jailrules"), remove them
 | 
					   echo "rm -rf /usr/jail/${name}"
 | 
				
			||||||
# Remove jail_$name_* lines from rc.conf
 | 
					# Remove jail_$name_* lines from rc.conf
 | 
				
			||||||
 | 
					   echo <<-EOF
 | 
				
			||||||
 | 
					      sed -i '.bak' "/^jail_${name}_/d" /etc/rc.conf
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
# Remove " $name " from jail_list if it's there
 | 
					# Remove " $name " from jail_list if it's there
 | 
				
			||||||
 | 
					   echo <<-EOF
 | 
				
			||||||
 | 
					      eval $(grep '^jail_list=' /etc/rc.conf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      for JAIL in ${jail_list}; do
 | 
				
			||||||
 | 
					         if [ ! "${JAIL}" = "${name}" ]; then
 | 
				
			||||||
 | 
					            new_list="${new_list} ${JAIL}"
 | 
				
			||||||
 | 
					         fi
 | 
				
			||||||
 | 
					      done
 | 
				
			||||||
 | 
					      jail_list="${new_list}"
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"${jail_list}\"/" /etc/rc.conf
 | 
				
			||||||
 | 
					      unset jail_list
 | 
				
			||||||
 | 
					      rm -f /etc/rc.conf.bak
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
createJail() {
 | 
					createJail() {
 | 
				
			||||||
| 
						 | 
					@ -194,8 +212,9 @@ if [ "$onboot" = "true" ]; then
 | 
				
			||||||
   echo <<-EOF
 | 
					   echo <<-EOF
 | 
				
			||||||
      eval $(grep '^jail_list=' /etc/rc.conf)
 | 
					      eval $(grep '^jail_list=' /etc/rc.conf)
 | 
				
			||||||
      jail_list="${jail_list} ${name}"
 | 
					      jail_list="${jail_list} ${name}"
 | 
				
			||||||
      sed -i "s/^jail_list=\".*\"/jail_list=\"${jail_list}\"/" /etc/rc.conf
 | 
					      sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"${jail_list}\"/" /etc/rc.conf
 | 
				
			||||||
      unset jail_list
 | 
					      unset jail_list
 | 
				
			||||||
 | 
					      rm -f /etc/rc.conf.bak
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue