winip=$(ip route | grep default | awk '{print $3}') if [ $winip ];then Log "windows ip:$winip" export winip=$winip else Log "get Windows ip falut,Exiting...." Exit fi
wslip=$(ifconfig eth0 | grep 'inet ' | awk '{print $2}') if [ $wslip ];then Log "WSL ip:$wslip" export wslip=$wslip else Log "get WSL ip falut,Exiting...." Exit fi
# update windows hosts # rm $tmp if [ ! -f $tmp ]; then Log $(touch$tmp && echo"touch $tmp") else Log "tmp file:$tmp" fi
Log "process windows hosts" sed '/win.host/d'$win_hosts_path | sed '/wsl.host/d'| sed '/#Update At/d' | sed '/'"$msg"'/d' | sed '$a'"$msg$winip win.host\n$wslip wsl.host\n#Update At $startDate" > $tmp
Log 'writting windows hosts' cat$tmp > $win_hosts_path if [ $? -eq 0 ];then Log "write successfully" else Log "write fail" Exit fi
Log "process wsl hosts" sed "/win.host/d" /etc/hosts | sed "/wsl.host/d" | sed "/Update At/d" | sed '/'"$msg"'/d' | sed '$a'"$msg$winip win.host\n$wslip wsl.host\n#Update At $startDate" > $tmp
# Automatically mount Windows drive when the distribution is launched [automount]
# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab. enabled = true
# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c. root = /mnt/
# DrvFs-specific options can be specified. options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off"
# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched. mountFsTab = true
# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1). [network] hostname = Su generateHosts = false generateResolvConf = false
# Set whether WSL supports interop process like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables. [interop] enabled = false appendWindowsPath = false
# Set the user when launching a distribution with WSL. [user] default = aja
# Set a command to run when a new WSL instance launches. This example starts the Docker container service. [boot] command = /bin/bash /opt/cron/boot.sh >> /var/log/user/iboot.log
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 172.22.240.1
# Automatically mount Windows drive when the distribution is launched [automount]
# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab. enabled = true
# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c. root = /mnt/
# DrvFs-specific options can be specified. options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off"
# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched. mountFsTab = true
# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1). [network] hostname = Su generateHosts = false generateResolvConf = false
# Set whether WSL supports interop process like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables. [interop] enabled = false appendWindowsPath = false
# Set the user when launching a distribution with WSL. [user] default = aja
# Set a command to run when a new WSL instance launches. This example starts the Docker container service. [boot] command = /bin/bash /opt/cron/boot.sh >> /var/log/user/iboot.log
# update windows hosts if [ ! -f $tmp ]; then echo $(touch$tmp && echo"touch $tmp") else echo"tmp file:$tmp" fi
echo"process windows hosts" sed '/win.host/d'$win_hosts_path | sed '/wsl.host/d'| sed '/#Update At/d' | sed '/'"$msg"'/d' | sed '$a'"$msg$winip win.host\n$wslip wsl.host\n#Update At $startDate" > $tmp
echo'writting windows hosts' cat$tmp > $win_hosts_path if [ $? -eq 0 ];then echo"write successfully" else echo"write fail" fi
echo"process wsl hosts" sed "/win.host/d" /etc/hosts | sed "/wsl.host/d" | sed "/Update At/d" | sed '/'"$msg"'/d' | sed '$a'"$msg$winip win.host\n$wslip wsl.host\n#Update At $startDate" > $tmp
echo'writing wsl hosts' cat$tmp > /etc/hosts if [ $? -eq 0 ];then echo"write successfully" else echo"write fail" fi
endDate=`date +"%Y-%m-%d %H:%M:%S"` echo"----------- Script Finished At $endDate ----------"
Comments