summaryrefslogblamecommitdiffstats
path: root/modules.d/slx-network/hooks/s3-copy-network-files.sh
blob: 0b8577c0c77a64580cb3550ac84d10e859c484e3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
          
 











                                                                              
 




                                                                    
 
      
#!/bin/ash

# backup network configuration files found in stage4, copy ours
for file in "hostname" "hosts" "resolv.conf"; do
	file="/etc/$file"
	if ! [ -e "$file" ]; then
		echo "Missing '$file' - can't move it to stage4. "
		continue
	fi
	if [ -e "${NEWROOT}/${file}" ] || [ -h "${NEWROOT}/${file}" ]; then
		mv "${NEWROOT}/${file}" "${NEWROOT}/${file}.renamed-by-stage3"
	fi
	cp -af -- "$file" "${NEWROOT}${file}"
done

# special handling for resolv.conf:
# move it to /opt/openslx to detect we are managing it
mkdir -p "${NEWROOT}/opt/openslx"
mv "${NEWROOT}/etc/resolv.conf" "${NEWROOT}/opt/openslx/resolv.conf"
ln -nfs "/opt/openslx/resolv.conf" "${NEWROOT}/etc/resolv.conf"

exit 0