mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-31 04:44:05 +02:00
Beautify bash
This commit is contained in:
@@ -11,10 +11,10 @@ if [ -e "/MODULESFILE" ]; then
|
||||
echo "Executing modules script : $MODULES"
|
||||
|
||||
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& mkdir -p /etc/cont-init.d \
|
||||
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
|
||||
&& chmod -R 755 /etc/cont-init.d
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& mkdir -p /etc/cont-init.d \
|
||||
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
|
||||
&& chmod -R 755 /etc/cont-init.d
|
||||
fi
|
||||
|
||||
#######################
|
||||
@@ -25,9 +25,9 @@ if [ -e "/ENVFILE" ]; then
|
||||
echo "Executing dependency script with custom elements : $PACKAGES"
|
||||
|
||||
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
|
||||
&& chmod 777 /automatic_packages.sh \
|
||||
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
|
||||
&& rm /automatic_packages.sh
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
|
||||
&& chmod 777 /automatic_packages.sh \
|
||||
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
|
||||
&& rm /automatic_packages.sh
|
||||
fi
|
||||
|
||||
@@ -39,7 +39,7 @@ LATEST_RELEASE=$(curl -f -s --retry 5 -L https://api.github.com/repos/wdaan/vuet
|
||||
grep "browser_download_url.*zip" |
|
||||
cut -d : -f 2,3 |
|
||||
tr -d \" |
|
||||
xargs)
|
||||
xargs)
|
||||
|
||||
[ "$DEBUG" = "debug" ] && echo "Before curl"
|
||||
curl -f -s -S -O -J -L "$LATEST_RELEASE"
|
||||
|
||||
@@ -16,11 +16,11 @@ LINE=$((LINE + 1))
|
||||
###########
|
||||
|
||||
if bashio::config.has_value 'run_duration'; then
|
||||
rm /etc/services.d/qbittorrent/run
|
||||
mv /etc/services.d/qbittorrent/timer /etc/services.d/qbittorrent/run
|
||||
chmod +x /etc/services.d/qbittorrent/run
|
||||
rm /etc/services.d/qbittorrent/run
|
||||
mv /etc/services.d/qbittorrent/timer /etc/services.d/qbittorrent/run
|
||||
chmod +x /etc/services.d/qbittorrent/run
|
||||
else
|
||||
rm /etc/services.d/qbittorrent/timer
|
||||
rm /etc/services.d/qbittorrent/timer
|
||||
fi
|
||||
|
||||
##################
|
||||
@@ -33,16 +33,16 @@ DOWNLOADS=$(bashio::config 'SavePath')
|
||||
# Set configuration
|
||||
if bashio::config.has_value 'SavePath'; then
|
||||
|
||||
# Replace save path
|
||||
CURRENTSAVEPATH=$(sed -n '/Downloads\\SavePath/p' qBittorrent.conf)
|
||||
sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true
|
||||
# Replace save path
|
||||
CURRENTSAVEPATH=$(sed -n '/Downloads\\SavePath/p' qBittorrent.conf)
|
||||
sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true
|
||||
|
||||
# Replace session save path
|
||||
CURRENTSAVEPATH=$(sed -n '/Session\\DefaultSavePath/p' qBittorrent.conf)
|
||||
sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true
|
||||
# Replace session save path
|
||||
CURRENTSAVEPATH=$(sed -n '/Session\\DefaultSavePath/p' qBittorrent.conf)
|
||||
sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true
|
||||
|
||||
# Info
|
||||
bashio::log.info "Downloads can be found in $DOWNLOADS"
|
||||
# Info
|
||||
bashio::log.info "Downloads can be found in $DOWNLOADS"
|
||||
fi
|
||||
|
||||
# Create default location
|
||||
@@ -78,15 +78,15 @@ sed -i '/HTTPS/d' qBittorrent.conf
|
||||
|
||||
bashio::config.require.ssl
|
||||
if bashio::config.true 'ssl'; then
|
||||
bashio::log.info "ssl enabled. If webui don't work, disable ssl or check your certificate paths"
|
||||
#set variables
|
||||
CERTFILE=$(bashio::config 'certfile')
|
||||
KEYFILE=$(bashio::config 'keyfile')
|
||||
bashio::log.info "ssl enabled. If webui don't work, disable ssl or check your certificate paths"
|
||||
#set variables
|
||||
CERTFILE=$(bashio::config 'certfile')
|
||||
KEYFILE=$(bashio::config 'keyfile')
|
||||
|
||||
#Modify configuration
|
||||
sed -i "$LINE i\WebUI\\\HTTPS\\\Enabled=True" qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\HTTPS\\\CertificatePath=/ssl/$CERTFILE" qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\HTTPS\\\KeyPath=/ssl/$KEYFILE" qBittorrent.conf
|
||||
#Modify configuration
|
||||
sed -i "$LINE i\WebUI\\\HTTPS\\\Enabled=True" qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\HTTPS\\\CertificatePath=/ssl/$CERTFILE" qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\HTTPS\\\KeyPath=/ssl/$KEYFILE" qBittorrent.conf
|
||||
fi
|
||||
|
||||
################
|
||||
@@ -95,12 +95,12 @@ fi
|
||||
|
||||
cd /config/qBittorrent/ || true
|
||||
if bashio::config.has_value 'whitelist'; then
|
||||
WHITELIST=$(bashio::config 'whitelist')
|
||||
#clean data
|
||||
sed -i '/AuthSubnetWhitelist/d' qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\AuthSubnetWhitelistEnabled=true" qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\AuthSubnetWhitelist=$WHITELIST" qBittorrent.conf
|
||||
bashio::log.info "Whitelisted subsets will not require a password : $WHITELIST"
|
||||
WHITELIST=$(bashio::config 'whitelist')
|
||||
#clean data
|
||||
sed -i '/AuthSubnetWhitelist/d' qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\AuthSubnetWhitelistEnabled=true" qBittorrent.conf
|
||||
sed -i "$LINE i\WebUI\\\AuthSubnetWhitelist=$WHITELIST" qBittorrent.conf
|
||||
bashio::log.info "Whitelisted subsets will not require a password : $WHITELIST"
|
||||
fi
|
||||
|
||||
###############
|
||||
@@ -109,12 +109,12 @@ fi
|
||||
|
||||
cd /config/qBittorrent/ || true
|
||||
if bashio::config.has_value 'Username'; then
|
||||
USERNAME=$(bashio::config 'Username')
|
||||
#clean data
|
||||
sed -i '/WebUI\\\Username/d' qBittorrent.conf
|
||||
#add data
|
||||
sed -i "$LINE i\WebUI\\\Username=$USERNAME" qBittorrent.conf
|
||||
bashio::log.info "WEBUI username set to $USERNAME"
|
||||
USERNAME=$(bashio::config 'Username')
|
||||
#clean data
|
||||
sed -i '/WebUI\\\Username/d' qBittorrent.conf
|
||||
#add data
|
||||
sed -i "$LINE i\WebUI\\\Username=$USERNAME" qBittorrent.conf
|
||||
bashio::log.info "WEBUI username set to $USERNAME"
|
||||
fi
|
||||
|
||||
################
|
||||
@@ -135,17 +135,17 @@ if bashio::config.has_value 'customUI' && [ ! "$CUSTOMUI" = default ]; then
|
||||
|
||||
### Download WebUI
|
||||
case $CUSTOMUI in
|
||||
"vuetorrent")
|
||||
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/WDaan/VueTorrent/releases/latest | grep -o "http.*vuetorrent.zip" | head -1)" >/dev/null
|
||||
;;
|
||||
"vuetorrent")
|
||||
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/WDaan/VueTorrent/releases/latest | grep -o "http.*vuetorrent.zip" | head -1)" >/dev/null
|
||||
;;
|
||||
|
||||
"qbit-matUI")
|
||||
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/bill-ahmed/qbit-matUI/releases/latest | grep -o "http.*Unix.*.zip" | head -1)" >/dev/null
|
||||
;;
|
||||
"qbit-matUI")
|
||||
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/bill-ahmed/qbit-matUI/releases/latest | grep -o "http.*Unix.*.zip" | head -1)" >/dev/null
|
||||
;;
|
||||
|
||||
"qb-web")
|
||||
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/CzBiX/qb-web/releases | grep -o "http.*qb-web-.*zip" | head -1)" >/dev/null
|
||||
;;
|
||||
"qb-web")
|
||||
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/CzBiX/qb-web/releases | grep -o "http.*qb-web-.*zip" | head -1)" >/dev/null
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
@@ -8,84 +8,84 @@ declare openvpn_password
|
||||
|
||||
if bashio::config.true 'openvpn_enabled'; then
|
||||
|
||||
bashio::log.info "Configuring openvpn"
|
||||
bashio::log.info "Configuring openvpn"
|
||||
|
||||
###############
|
||||
# ENABLE IPV6 #
|
||||
###############
|
||||
|
||||
# { echo "net.ipv6.conf.all.disable_ipv6 = 0";
|
||||
# echo "net.ipv6.conf.default.disable_ipv6 = 0";
|
||||
# echo "net.ipv6.conf.lo.disable_ipv6 = 0"; } >> /etc/sysctl.conf || true
|
||||
|
||||
# sysctl -p || true
|
||||
###############
|
||||
# ENABLE IPV6 #
|
||||
###############
|
||||
|
||||
#####################
|
||||
# CONFIGURE OPENVPN #
|
||||
#####################
|
||||
# { echo "net.ipv6.conf.all.disable_ipv6 = 0";
|
||||
# echo "net.ipv6.conf.default.disable_ipv6 = 0";
|
||||
# echo "net.ipv6.conf.lo.disable_ipv6 = 0"; } >> /etc/sysctl.conf || true
|
||||
|
||||
openvpn_config=$(bashio::config 'openvpn_config')
|
||||
# sysctl -p || true
|
||||
|
||||
cp "/config/openvpn/${openvpn_config}" /etc/openvpn/config.ovpn || bashio::log.error "openvpn config file not found in /config/openvpn/${openvpn_config}"
|
||||
#####################
|
||||
# CONFIGURE OPENVPN #
|
||||
#####################
|
||||
|
||||
openvpn_username=$(bashio::config 'openvpn_username')
|
||||
echo "${openvpn_username}" >/etc/openvpn/credentials
|
||||
openvpn_password=$(bashio::config 'openvpn_password')
|
||||
echo "${openvpn_password}" >>/etc/openvpn/credentials
|
||||
sed -i 's/auth-user-pass.*/auth-user-pass \/etc\/openvpn\/credentials/g' /etc/openvpn/config.ovpn
|
||||
openvpn_config=$(bashio::config 'openvpn_config')
|
||||
|
||||
# Permissions
|
||||
chmod 600 /etc/openvpn/credentials
|
||||
chmod 755 /etc/openvpn/up.sh
|
||||
chmod 755 /etc/openvpn/down.sh
|
||||
chmod 755 /etc/openvpn/up-qbittorrent.sh
|
||||
chmod +x /etc/openvpn/up.sh
|
||||
chmod +x /etc/openvpn/up-qbittorrent.sh
|
||||
cp "/config/openvpn/${openvpn_config}" /etc/openvpn/config.ovpn || bashio::log.error "openvpn config file not found in /config/openvpn/${openvpn_config}"
|
||||
|
||||
bashio::log.info "openvpn correctly set, qbittorrent will run tunnelled through openvpn"
|
||||
openvpn_username=$(bashio::config 'openvpn_username')
|
||||
echo "${openvpn_username}" >/etc/openvpn/credentials
|
||||
openvpn_password=$(bashio::config 'openvpn_password')
|
||||
echo "${openvpn_password}" >>/etc/openvpn/credentials
|
||||
sed -i 's/auth-user-pass.*/auth-user-pass \/etc\/openvpn\/credentials/g' /etc/openvpn/config.ovpn
|
||||
|
||||
#########################
|
||||
# CONFIGURE QBITTORRENT #
|
||||
#########################
|
||||
# Permissions
|
||||
chmod 600 /etc/openvpn/credentials
|
||||
chmod 755 /etc/openvpn/up.sh
|
||||
chmod 755 /etc/openvpn/down.sh
|
||||
chmod 755 /etc/openvpn/up-qbittorrent.sh
|
||||
chmod +x /etc/openvpn/up.sh
|
||||
chmod +x /etc/openvpn/up-qbittorrent.sh
|
||||
|
||||
QBT_CONFIG_FILE="/config/qBittorrent/qBittorrent.conf"
|
||||
# Define preferences line
|
||||
cd /config/qBittorrent/ || exit 1
|
||||
LINE=$(sed -n '/Preferences/=' qBittorrent.conf)
|
||||
LINE=$((LINE + 1))
|
||||
SESSION=$(sed -n '/BitTorrent/=' qBittorrent.conf)
|
||||
bashio::log.info "openvpn correctly set, qbittorrent will run tunnelled through openvpn"
|
||||
|
||||
# If qBittorrent.conf exists
|
||||
if [ -f "$QBT_CONFIG_FILE" ]; then
|
||||
# Remove previous line and bind tun0
|
||||
sed -i '/Interface/d' qBittorrent.conf
|
||||
#########################
|
||||
# CONFIGURE QBITTORRENT #
|
||||
#########################
|
||||
|
||||
# Bind tun0
|
||||
sed -i "$LINE i\Connection\\\Interface=tun0" qBittorrent.conf
|
||||
sed -i "$LINE i\Connection\\\InterfaceName=tun0" qBittorrent.conf
|
||||
QBT_CONFIG_FILE="/config/qBittorrent/qBittorrent.conf"
|
||||
# Define preferences line
|
||||
cd /config/qBittorrent/ || exit 1
|
||||
LINE=$(sed -n '/Preferences/=' qBittorrent.conf)
|
||||
LINE=$((LINE + 1))
|
||||
SESSION=$(sed -n '/BitTorrent/=' qBittorrent.conf)
|
||||
|
||||
if [ "$SESSION" != "" ]; then
|
||||
SESSION=$((SESSION + 1))
|
||||
sed -i "$SESSION i\Session\\\Interface=tun0" qBittorrent.conf
|
||||
sed -i "$SESSION i\Session\\\InterfaceName=tun0" qBittorrent.conf
|
||||
# If qBittorrent.conf exists
|
||||
if [ -f "$QBT_CONFIG_FILE" ]; then
|
||||
# Remove previous line and bind tun0
|
||||
sed -i '/Interface/d' qBittorrent.conf
|
||||
|
||||
# Bind tun0
|
||||
sed -i "$LINE i\Connection\\\Interface=tun0" qBittorrent.conf
|
||||
sed -i "$LINE i\Connection\\\InterfaceName=tun0" qBittorrent.conf
|
||||
|
||||
if [ "$SESSION" != "" ]; then
|
||||
SESSION=$((SESSION + 1))
|
||||
sed -i "$SESSION i\Session\\\Interface=tun0" qBittorrent.conf
|
||||
sed -i "$SESSION i\Session\\\InterfaceName=tun0" qBittorrent.conf
|
||||
fi
|
||||
|
||||
else
|
||||
bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Modify ovpn config
|
||||
echo "route-nopull" >>/etc/openvpn/config.ovpn
|
||||
# Modify ovpn config
|
||||
echo "route-nopull" >>/etc/openvpn/config.ovpn
|
||||
|
||||
else
|
||||
|
||||
##################
|
||||
# REMOVE OPENVPN #
|
||||
##################
|
||||
# Ensure no redirection by removing the direction tag
|
||||
cd /config/qBittorrent/ || exit 1
|
||||
sed -i '/Interface/d' qBittorrent.conf
|
||||
bashio::log.info "Direct connection without VPN enabled"
|
||||
##################
|
||||
# REMOVE OPENVPN #
|
||||
##################
|
||||
# Ensure no redirection by removing the direction tag
|
||||
cd /config/qBittorrent/ || exit 1
|
||||
sed -i '/Interface/d' qBittorrent.conf
|
||||
bashio::log.info "Direct connection without VPN enabled"
|
||||
|
||||
fi
|
||||
|
||||
@@ -6,27 +6,27 @@
|
||||
|
||||
# If we have a service specific script, run this now
|
||||
if [ -x /etc/openvpn/"${RC_SVCNAME}"-down.sh ] ; then
|
||||
/etc/openvpn/"${RC_SVCNAME}"-down.sh "$@"
|
||||
/etc/openvpn/"${RC_SVCNAME}"-down.sh "$@"
|
||||
fi
|
||||
|
||||
# Restore resolv.conf to how it was
|
||||
if [ "${PEER_DNS}" != "no" ]; then
|
||||
if [ -x /sbin/resolvconf ] ; then
|
||||
/sbin/resolvconf -d "${dev}"
|
||||
elif [ -e /etc/resolv.conf-"${dev}".sv ] ; then
|
||||
# Important that we cat instead of move incase resolv.conf is
|
||||
# a symlink and not an actual file
|
||||
cat /etc/resolv.conf-"${dev}".sv > /etc/resolv.conf
|
||||
rm -f /etc/resolv.conf-"${dev}".sv
|
||||
fi
|
||||
if [ -x /sbin/resolvconf ] ; then
|
||||
/sbin/resolvconf -d "${dev}"
|
||||
elif [ -e /etc/resolv.conf-"${dev}".sv ] ; then
|
||||
# Important that we cat instead of move incase resolv.conf is
|
||||
# a symlink and not an actual file
|
||||
cat /etc/resolv.conf-"${dev}".sv > /etc/resolv.conf
|
||||
rm -f /etc/resolv.conf-"${dev}".sv
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${RC_SVCNAME}" ]; then
|
||||
# Re-enter the init script to start any dependant services
|
||||
if /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
|
||||
export IN_BACKGROUND=true
|
||||
/etc/init.d/"${RC_SVCNAME}" --quiet stop
|
||||
fi
|
||||
# Re-enter the init script to start any dependant services
|
||||
if /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
|
||||
export IN_BACKGROUND=true
|
||||
/etc/init.d/"${RC_SVCNAME}" --quiet stop
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -25,44 +25,44 @@
|
||||
# and try and let resolvconf handle it
|
||||
|
||||
if [ "${PEER_DNS}" != "no" ]; then
|
||||
NS=
|
||||
DOMAIN=
|
||||
SEARCH=
|
||||
i=1
|
||||
while true ; do
|
||||
eval opt=\$foreign_option_${i}
|
||||
[ -z "${opt}" ] && break
|
||||
if [ "${opt}" != "${opt#dhcp-option DOMAIN *}" ] ; then
|
||||
if [ -z "${DOMAIN}" ] ; then
|
||||
DOMAIN="${opt#dhcp-option DOMAIN *}"
|
||||
else
|
||||
SEARCH="${SEARCH}${SEARCH:+ }${opt#dhcp-option DOMAIN *}"
|
||||
fi
|
||||
elif [ "${opt}" != "${opt#dhcp-option DNS *}" ] ; then
|
||||
NS="${NS}nameserver ${opt#dhcp-option DNS *}\n"
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
done
|
||||
NS=
|
||||
DOMAIN=
|
||||
SEARCH=
|
||||
i=1
|
||||
while true ; do
|
||||
eval opt=\$foreign_option_${i}
|
||||
[ -z "${opt}" ] && break
|
||||
if [ "${opt}" != "${opt#dhcp-option DOMAIN *}" ] ; then
|
||||
if [ -z "${DOMAIN}" ] ; then
|
||||
DOMAIN="${opt#dhcp-option DOMAIN *}"
|
||||
else
|
||||
SEARCH="${SEARCH}${SEARCH:+ }${opt#dhcp-option DOMAIN *}"
|
||||
fi
|
||||
elif [ "${opt}" != "${opt#dhcp-option DNS *}" ] ; then
|
||||
NS="${NS}nameserver ${opt#dhcp-option DNS *}\n"
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
done
|
||||
|
||||
if [ -n "${NS}" ] ; then
|
||||
DNS="# Generated by openvpn for interface ${dev}\n"
|
||||
if [ -n "${SEARCH}" ] ; then
|
||||
DNS="${DNS}search ${DOMAIN} ${SEARCH}\n"
|
||||
elif [ -n "${DOMAIN}" ]; then
|
||||
DNS="${DNS}domain ${DOMAIN}\n"
|
||||
fi
|
||||
DNS="${DNS}${NS}"
|
||||
if [ -x /sbin/resolvconf ] ; then
|
||||
printf "${DNS}" | /sbin/resolvconf -a "${dev}"
|
||||
else
|
||||
# Preserve the existing resolv.conf
|
||||
if [ -e /etc/resolv.conf ] ; then
|
||||
cp /etc/resolv.conf /etc/resolv.conf-"${dev}".sv
|
||||
fi
|
||||
printf "${DNS}" > /etc/resolv.conf
|
||||
chmod 644 /etc/resolv.conf
|
||||
fi
|
||||
fi
|
||||
if [ -n "${NS}" ] ; then
|
||||
DNS="# Generated by openvpn for interface ${dev}\n"
|
||||
if [ -n "${SEARCH}" ] ; then
|
||||
DNS="${DNS}search ${DOMAIN} ${SEARCH}\n"
|
||||
elif [ -n "${DOMAIN}" ]; then
|
||||
DNS="${DNS}domain ${DOMAIN}\n"
|
||||
fi
|
||||
DNS="${DNS}${NS}"
|
||||
if [ -x /sbin/resolvconf ] ; then
|
||||
printf "${DNS}" | /sbin/resolvconf -a "${dev}"
|
||||
else
|
||||
# Preserve the existing resolv.conf
|
||||
if [ -e /etc/resolv.conf ] ; then
|
||||
cp /etc/resolv.conf /etc/resolv.conf-"${dev}".sv
|
||||
fi
|
||||
printf "${DNS}" > /etc/resolv.conf
|
||||
chmod 644 /etc/resolv.conf
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Below section is Gentoo specific
|
||||
@@ -70,16 +70,16 @@ fi
|
||||
# as we could have >1 openvpn service
|
||||
|
||||
if [ -n "${RC_SVCNAME}" ]; then
|
||||
# If we have a service specific script, run this now
|
||||
if [ -x /etc/openvpn/"${RC_SVCNAME}"-up.sh ] ; then
|
||||
/etc/openvpn/"${RC_SVCNAME}"-up.sh "$@"
|
||||
fi
|
||||
# If we have a service specific script, run this now
|
||||
if [ -x /etc/openvpn/"${RC_SVCNAME}"-up.sh ] ; then
|
||||
/etc/openvpn/"${RC_SVCNAME}"-up.sh "$@"
|
||||
fi
|
||||
|
||||
# Re-enter the init script to start any dependant services
|
||||
if ! /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
|
||||
export IN_BACKGROUND=true
|
||||
/etc/init.d/${RC_SVCNAME} --quiet start
|
||||
fi
|
||||
# Re-enter the init script to start any dependant services
|
||||
if ! /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
|
||||
export IN_BACKGROUND=true
|
||||
/etc/init.d/${RC_SVCNAME} --quiet start
|
||||
fi
|
||||
fi
|
||||
|
||||
###############
|
||||
|
||||
Reference in New Issue
Block a user