created install script
This commit is contained in:
		
							parent
							
								
									3dd7e915e1
								
							
						
					
					
						commit
						ab496871ad
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,2 +1,3 @@ | ||||
| dtrfs.tar | ||||
| build | ||||
| tmp | ||||
|  | ||||
| @ -8,13 +8,18 @@ cd build | ||||
| 
 | ||||
| echo_blue "Starting installation at $ROOT." | ||||
| 
 | ||||
| echo_blue "Adding kernel binaries..." | ||||
| install_busybox | ||||
| install_binary $(which modprobe) | ||||
| install_binary $(which switch_root) | ||||
| echo_blue "Adding scripts..." | ||||
| install_init_script | ||||
| install_module btrfs | ||||
| echo_blue "Adding kernel modules..." | ||||
| install_module "$(df -T / | awk '{ print $2 }' | tail -1)" | ||||
| install_module msr | ||||
| install_module sev-guest | ||||
| install_module dm_crypt | ||||
| cp /lib/modules/${KERNEL}/modules.{order,builtin,builtin.modinfo} "${ROOT}/lib/modules/${KERNEL}/" | ||||
| depmod -b "$ROOT" "$KERNEL" | ||||
| echo_blue "Creating archive..." | ||||
| create_archive | ||||
|  | ||||
| @ -22,7 +22,7 @@ install_dep() { | ||||
|    | ||||
|   [[ -f "${ROOT}${lib}" ]] || { | ||||
|     mkdir -p $(dirname "${ROOT}${lib}") | ||||
|     echo_blue "Adding dependency to root: $lib" | ||||
|     echo_blue "Adding dependency: $lib" | ||||
|     cp "$lib" "${ROOT}${lib}" | ||||
|   } | ||||
| } | ||||
| @ -37,7 +37,7 @@ install_binary() { | ||||
|     exit 1 | ||||
|   } | ||||
| 
 | ||||
|   echo_blue "Adding binary to root: $binary" | ||||
|   echo_blue "Adding binary: $binary" | ||||
|   cp "$binary" "${ROOT}/usr/bin/" | ||||
| 
 | ||||
|   ldd_deps="$(ldd "$binary")" | ||||
| @ -69,15 +69,22 @@ install_init_script() { | ||||
| } | ||||
| 
 | ||||
| create_archive() { | ||||
|   echo_blue "Creating archive..." | ||||
|   local archive="detee-$(hostnamectl hostname)-${KERNEL}.cpio.gz" | ||||
|   echo_blue "Creating archive $archive" | ||||
|   echo $archive > .archive_name | ||||
|   find . | cpio -o -H newc | gzip > detee-$(hostnamectl hostname)-${KERNEL}.cpio.gz | ||||
| } | ||||
| 
 | ||||
| install_module() { | ||||
|   local module="$1" depends='' dep='' filename='' | ||||
| 
 | ||||
|   filename="$( modinfo -k $KERNEL $module | grep '^filename:' | awk '{ print $2 }' )" | ||||
|   [[ "$filename" == "(builtin)" ]] && { | ||||
|     echo_yellow "Module $module is builtin. Installation not needed." | ||||
|     return 0 | ||||
|   } | ||||
| 
 | ||||
|   install_dep "$filename" | ||||
|   echo "insmod $filename" >> "${ROOT}/load_modules.sh" | ||||
| 
 | ||||
|   depends="$(modinfo -k $KERNEL $module | | ||||
|     grep '^depends:' | awk '{ print $2 }' | sed 's/,/\n/g')" | ||||
|  | ||||
| @ -9,7 +9,7 @@ echo_red() { | ||||
| } | ||||
| 
 | ||||
| load_modules() { | ||||
|   modprobe btrfs msr sev-guest || exit 1 | ||||
|   cat /load_modules.sh | sort -u | bash | ||||
| } | ||||
| 
 | ||||
| create_mounts() { | ||||
|  | ||||
							
								
								
									
										39
									
								
								install.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										39
									
								
								install.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,39 @@ | ||||
| #!/bin/bash | ||||
| cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" | ||||
| 
 | ||||
| dir="/tmp/dtrfs" | ||||
| 
 | ||||
| if [ -z $1 ]; then | ||||
|   echo "You must specify the server as the first parameter." | ||||
|   echo "Example: ./install.sh 10.10.10.73 root 22" | ||||
|   echo "The 2nd (ssh user) and 3rd (ssh port) arguments are optional." | ||||
|   exit 1 | ||||
| fi | ||||
| 
 | ||||
| server="$1" | ||||
| 
 | ||||
| if ! [ -z $2 ]; then | ||||
|   server="${2}@${server}" | ||||
| fi | ||||
| 
 | ||||
| if [ -z $3 ]; then | ||||
|   ssh="ssh" | ||||
|   scp="scp" | ||||
| else | ||||
|   ssh="ssh -p $3" | ||||
|   scp="scp -P $3" | ||||
| fi | ||||
| 
 | ||||
| echo Starting installation... | ||||
| 
 | ||||
| tar cf dtrfs.tar *.sh | ||||
| $ssh $server rm -rf ${dir} | ||||
| $ssh $server mkdir -p ${dir} | ||||
| $scp dtrfs.tar ${server}:${dir} | ||||
| $ssh $server tar -xf ${dir}/dtrfs.tar -C ${dir} | ||||
| $ssh $server ${dir}/create.sh | ||||
| set -e  | ||||
| archive=$($ssh $server cat ${dir}/build/.archive_name) | ||||
| mkdir -p tmp | ||||
| $scp ${server}:${dir}/build/${archive} tmp/ | ||||
| echo initrd downloaded to: $(pwd)/tmp/${archive} | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user