mirror of
https://github.com/elitak/nixos-infect
synced 2024-11-22 11:13:08 +00:00
SC2086: Double quote to prevent globbing and word splitting
This commit is contained in:
parent
ff398f6447
commit
3bd6fe9352
1 changed files with 14 additions and 14 deletions
28
nixos-infect
28
nixos-infect
|
@ -39,17 +39,17 @@ EOF
|
|||
# XXX It'd be better if we used procfs for all this...
|
||||
local IFS=$'\n'
|
||||
eth0_name=$(ip address show | grep '^2:' | awk -F': ' '{print $2}')
|
||||
eth0_ip4s=($(ip address show dev $eth0_name | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
|
||||
eth0_ip6s=($(ip address show dev $eth0_name | grep 'inet6 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || ''))
|
||||
gateway=($(ip route show dev $eth0_name | grep default | sed -r 's|default via ([0-9.]+).*|\1|'))
|
||||
ether0=($(ip address show dev $eth0_name | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
|
||||
eth0_ip4s=($(ip address show dev "$eth0_name" | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
|
||||
eth0_ip6s=($(ip address show dev "$eth0_name" | grep 'inet6 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || ''))
|
||||
gateway=($(ip route show dev "$eth0_name" | grep default | sed -r 's|default via ([0-9.]+).*|\1|'))
|
||||
ether0=($(ip address show dev "$eth0_name" | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
|
||||
|
||||
eth1_name=$(ip address show | grep '^3:' | awk -F': ' '{print $2}')||true
|
||||
if [ -n "$eth1_name" ];then
|
||||
eth1_ip4s=($(ip address show dev $eth1_name | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
|
||||
eth1_ip6s=($(ip address show dev $eth1_name | grep 'inet6 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || ''))
|
||||
ether1=($(ip address show dev $eth1_name | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
|
||||
gateway6=($(ip -6 route show dev $eth1_name | grep default | sed -r 's|default via ([0-9a-f:]+).*|\1|' || true))
|
||||
eth1_ip4s=($(ip address show dev "$eth1_name" | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
|
||||
eth1_ip6s=($(ip address show dev "$eth1_name" | grep 'inet6 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || ''))
|
||||
ether1=($(ip address show dev "$eth1_name" | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
|
||||
gateway6=($(ip -6 route show dev "$eth1_name" | grep default | sed -r 's|default via ([0-9a-f:]+).*|\1|' || true))
|
||||
interfaces1=<< EOF
|
||||
$eth1_name = {
|
||||
ip4 = [$(for a in "${eth1_ip4s[@]}"; do echo -n "
|
||||
|
@ -113,17 +113,17 @@ EOF
|
|||
makeSwap() {
|
||||
# TODO check currently available swapspace first
|
||||
swapFile=`mktemp /tmp/nixos-infect.XXXXX.swp`
|
||||
dd if=/dev/zero of=$swapFile bs=1M count=$((1*1024))
|
||||
chmod 0600 $swapFile
|
||||
mkswap $swapFile
|
||||
swapon -v $swapFile
|
||||
dd if=/dev/zero "of=$swapFile" bs=1M count=$((1*1024))
|
||||
chmod 0600 "$swapFile"
|
||||
mkswap "$swapFile"
|
||||
swapon -v "$swapFile"
|
||||
}
|
||||
|
||||
removeSwap() {
|
||||
for swapFile in /tmp/nixos-infect.*.swp
|
||||
do
|
||||
swapoff -v $swapFile
|
||||
rm -vf $swapFile
|
||||
swapoff -v "$swapFile"
|
||||
rm -vf "$swapFile"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue