Beautify bash

This commit is contained in:
alexbelgium
2022-04-10 00:11:35 +00:00
committed by GitHub
parent 03e9103b64
commit 58ccbe24da

View File

@@ -63,41 +63,41 @@ if bashio::config.true 'openvpn_enabled'; then
# WITH INTERFACE BINDING # WITH INTERFACE BINDING
######################### #########################
# Connection with interface binding # Connection with interface binding
echo "Using interface binding in the qBittorrent app" echo "Using interface binding in the qBittorrent app"
# Define preferences line # Define preferences line
cd /config/qBittorrent/ || exit 1 cd /config/qBittorrent/ || exit 1
LINE=$(sed -n '/Preferences/=' "$QBT_CONFIG_FILE") LINE=$(sed -n '/Preferences/=' "$QBT_CONFIG_FILE")
LINE=$((LINE + 1)) LINE=$((LINE + 1))
SESSION=$(sed -n '/BitTorrent/=' "$QBT_CONFIG_FILE") SESSION=$(sed -n '/BitTorrent/=' "$QBT_CONFIG_FILE")
# If qBittorrent.conf exists # If qBittorrent.conf exists
if [ -f "$QBT_CONFIG_FILE" ]; then if [ -f "$QBT_CONFIG_FILE" ]; then
# Remove previous line and bind tun0 # Remove previous line and bind tun0
echo "... deleting previous interface settings" echo "... deleting previous interface settings"
sed -i '/Interface/d' "$QBT_CONFIG_FILE" sed -i '/Interface/d' "$QBT_CONFIG_FILE"
# Bind tun0 # Bind tun0
echo "... binding tun0 interface in qBittorrent configuration" echo "... binding tun0 interface in qBittorrent configuration"
sed -i "$LINE i\Connection\\\Interface=tun0" "$QBT_CONFIG_FILE" sed -i "$LINE i\Connection\\\Interface=tun0" "$QBT_CONFIG_FILE"
sed -i "$LINE i\Connection\\\InterfaceName=tun0" "$QBT_CONFIG_FILE" sed -i "$LINE i\Connection\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
if [ "$SESSION" != "" ]; then if [ "$SESSION" != "" ]; then
SESSION=$((SESSION + 1)) SESSION=$((SESSION + 1))
sed -i "$SESSION i\Session\\\Interface=tun0" "$QBT_CONFIG_FILE" sed -i "$SESSION i\Session\\\Interface=tun0" "$QBT_CONFIG_FILE"
sed -i "$SESSION i\Session\\\InterfaceName=tun0" "$QBT_CONFIG_FILE" sed -i "$SESSION i\Session\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
fi
else
bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options "
exit 1
fi fi
# Modify ovpn config else
if ! grep -q route-nopull /etc/openvpn/config.ovpn; then bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options "
echo "... adding route-nopull to your config.ovpn" exit 1
echo "route-nopull" >>/etc/openvpn/config.ovpn fi
fi
# Modify ovpn config
if ! grep -q route-nopull /etc/openvpn/config.ovpn; then
echo "... adding route-nopull to your config.ovpn"
echo "route-nopull" >>/etc/openvpn/config.ovpn
fi
else else