You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ublinux-init/ublinux/rc.preinit.d/30-network

99 lines
4.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
#
# Initial script for Live operating system
# This script are launching before starting init from linux-live script.
# Current dir allways must be set to root (/)
# All system path must be relative, except initrd dirs
ENABLED=yes
[ "$ENABLED" != "yes" ] && exit 0
DEBUGMODE=no
PATH=.:/:/usr/bin:/usr/local/bin:/usr/local/sbin
HOSTNAME=ublinux-live
unset ROOTFS; [[ -d /usr/lib/ublinux ]] || ROOTFS=.
SOURCE=${ROOTFS}/usr/lib/ublinux/functions; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null || exit 0
SOURCE=${ROOTFS}/usr/lib/ublinux/os-config; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null || exit 0
debug_mode "$0" "$@"
SYSCONF="${ROOTFS}/${SYSCONF}"
SOURCE=${SYSCONF}/config; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null
SOURCE=${SYSCONF}/network; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null
echo "127.0.0.1 sb-ssl.l.google.com safebrowsing.clients.google.com safebrowsing.cache.l.google.com" >> etc/hosts
grep -q "127\.0\.0\.1\s{1,}${HOSTNAME%%.*}\s*$" etc/hosts || echo "127.0.0.1 ${HOSTNAME%%.*}" >> etc/hosts
if [[ ${DOMAIN} != "" ]]; then
HOSTNAME="${HOSTNAME%%.*}.${DOMAIN}"
grep -q "127\.0\.0\.1\s{1,}${HOSTNAME}\s*$" etc/hosts || echo "127.0.0.1 ${HOSTNAME}" >> etc/hosts
## Указать доменных пользователей AccountsService, что-бы были видны для выбора логина в DM
ls -d home/*@*/ 2>/dev/null | xargs -ri basename {} | xargs -ri touch var/lib/AccountsService/users/{}
## Домен для сервера dhcpd
sed -i s/"option domain-name .*"/"option domain-name \"${DOMAIN}\";"/g etc/dhcpd.conf
sed -i s/"option nis-domain .*"/"option nis-domain \"${DOMAIN}\";"/g etc/dhcpd.conf
## Имя хоста записать в конфиг с постфиксом домена
sed -i /^HOSTNAME=/d etc/ublinux/config
echo "HOSTNAME=${HOSTNAME}" >> etc/ublinux/config
fi
echo "${HOSTNAME}" > etc/hostname
#if [ "$UBLINUXSERVER" != "" ] ;then
# sed -i s/.*ublinux-server.*/"$UBLINUXSERVER UBLinux-Server"/ etc/hosts
# sed -i s/192.168.1.31/$UBLINUXSERVER/g etc/dhcpd.conf
#fi
#if [ "$NETWORKIP" != "" ] ;then
# sed -i s/192.168.1./$NETWORKIP/g etc/dhcpd.conf
# sed -i s/192.168.1./$NETWORKIP/g etc/pdnsd.conf
# sed -i s/192.168.1./$NETWORKIP/g etc/samba/smb.conf
# sed -i s/192.168.1.0/${NETWORKIP}0/g etc/exports
# sed -i s/192.168.1.0/${NETWORKIP}0/g etc/polipo/config
# sed -i s/192.168.1.0/${NETWORKIP}0/g etc/ntp.conf
# sed -i s/192.168.1.0/${NETWORKIP}0/g etc/ublinux/iptables
#fi
## Указать системные прокси
if [[ -n ${HTTP_PROXY} ]]; then
echo "setenv http_proxy $HTTP_PROXY" > etc/profile.d/proxy.csh
echo "setenv https_proxy $HTTPS_PROXY" >> etc/profile.d/proxy.csh
echo "http_proxy=$HTTP_PROXY" > etc/profile.d/proxy.sh
echo "https_proxy=$HTTPS_PROXY" >> etc/profile.d/proxy.sh
echo "export http_proxy https_proxy" >> etc/profile.d/proxy.sh
fi
if [[ -n ${FTP_PROXY} ]]; then
echo "setenv ftp_proxy $FTP_PROXY" >> etc/profile.d/proxy.csh
echo "ftp_proxy=$FTP_PROXY" >> etc/profile.d/proxy.sh
echo "export ftp_proxy" >> etc/profile.d/proxy.sh
fi
if [[ -n ${NO_PROXY} ]]; then
echo "setenv no_proxy $NO_PROXY" >> etc/profile.d/proxy.csh
echo "no_proxy=$NO_PROXY" >> etc/profile.d/proxy.sh
echo "export no_proxy" >> etc/profile.d/proxy.sh
fi
[[ -n ${HTTP_PROXY} || -n ${FTP_PROXY} || -n ${NO_PROXY} ]] && chmod 755 etc/profile.d/proxy.sh etc/profile.d/proxy.csh
## Режим полного WiFi радио молчания
if [ "$(cmdline_parameter flightmode)" ] ;then
for a in etc/ublinux/network-scripts/ifcfg-w* ;do
sed -i s/ONBOOT=yes/ONBOOT=no/ $a 2>/dev/null
done
chroot . /usr/bin/rfkill block all
[ "$BLOCKWPASS" = "yes" -a -f usr/lib/systemd/system/wpa_supplicant.service ] && ln -sf /dev/null etc/systemd/system/wpa_supplicant.service
fi
if [ "$IPV6" = "yes" ] ;then
sed -i /ipv4/d usr/lib/systemd/network/90-enable.network 2>/dev/null
sed -i /ipv4/d usr/lib/systemd/network/90-wireless.network 2>/dev/null
sed -i /ipv6/d etc/modprobe.d/ublinux.conf 2>/dev/null
elif [ "$IPV6" = "no" ] ;then
sed -i /ipv4/d usr/lib/systemd/network/90-enable.network 2>/dev/null
sed -i /ipv4/d usr/lib/systemd/network/90-wireless.network 2>/dev/null
sed -i /ipv6/d etc/modprobe.d/ublinux.conf 2>/dev/null
echo "options ipv6 disable=1" >> etc/modprobe.d/ublinux.conf
echo "DHCP=ipv4" >> usr/lib/systemd/network/90-enable.network
echo "DHCP=ipv4" >> usr/lib/systemd/network/90-wireless.network
fi