Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
aronunger-ctb authored Dec 25, 2024
1 parent 8900e86 commit 93f572f
Showing 1 changed file with 211 additions and 0 deletions.
211 changes: 211 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#!/bin/bash

configure_vpn() {
mkdir -p /usr/share/tuxprotect/vpn/

echo "Please select your VPN server location:"
echo "1) US Server (New York)"
echo "2) UK Server (London)"
echo "3) Israel Server (Tel Aviv)"
read -p "Enter your choice (1-3): " choice

read -p "Enter your NetFree username: " vpn_user
while [ -z "$vpn_user" ]; do
echo "Username cannot be empty"
read -p "Enter your NetFree username: " vpn_user
done

read -s -p "Enter your NetFree password: " vpn_pass
while [ -z "$vpn_pass" ]; do
echo -e "\nPassword cannot be empty"
read -s -p "Enter your NetFree password: " vpn_pass
done
echo

local remote_line=""
case $choice in
1) remote_line="remote 173.68.147.11 143" ;;
2) remote_line="remote 77.68.76.69 143" ;;
3) remote_line="remote 185.217.99.140 143" ;;
*) remote_line="remote 173.68.147.11 143" ;;
esac

cat > netfree.ovpn << EOF
dev tun
$remote_line
fast-io
client
persist-key
persist-tun
proto tcp
comp-lzo
tls-client
verb 5
mute 10
auth-user-pass inline
<auth-user-pass>
$vpn_user
$vpn_pass
</auth-user-pass>
<ca>
-----BEGIN CERTIFICATE-----
MIIE6zCCA9OgAwIBAgIJALVqGDUdI6IrMA0GCSqGSIb3DQEBCwUAMIGpMQswCQYD
VQQGEwJVUzELMAkGA1UECBMCQ0ExFTATBgNVBAcTDFNhbkZyYW5jaXNjbzEVMBMG
A1UEChMMRm9ydC1GdW5zdG9uMRAwDgYDVQQLEwduZXRmcmVlMRgwFgYDVQQDEw9G
b3J0LUZ1bnN0b24gQ0ExEDAOBgNVBCkTB0Vhc3lSU0ExITAfBgkqhkiG9w0BCQEW
Em1lQG15aG9zdC5teWRvbWFpbjAeFw0xNTEyMTgwMzI2NDNaFw0yNTEyMTUwMzI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866VsgjzvCEWlGdgbDtpM1Uy54jGekUIYsAFB1WLt7LHNOkfpZCV0b
9t7wcbeVDzcYhRycC5DVwAG6NJ2LQw8xO830/kRi1N6sp8TSyaxuWrGacnjfn9yX
yJBh5mW+GKqSH507waB5tXOif5cD0J5RTCg7gLXWAYnOhEawqUZFR4zjRYdDo1oq
n1uFhnyKQch7KWz2OYecXvKdK3Hxkojw4jnefk1nhahlmZPhHTZsf74dXHFtcMAM
n9V1T/qhQHMcI3UX/H/WQJQoy5LJBRbLDzViobNH/SwR4AaHMWAHnQS2ddRTAUXf
NjA2WdgN4NlbtpidNFWx
-----END CERTIFICATE-----
</ca>
EOF

}

test_vpn_connection() {
echo "Testing VPN connection..."
timeout 30 openvpn --config netfree.ovpn --daemon
sleep 10

# Check if VPN is connected and has correct IP
if ip addr show tun0 >/dev/null 2>&1; then
vpn_ip=$(ip addr show tun0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
if [ -n "$vpn_ip" ]; then
echo "VPN connected successfully with IP: $vpn_ip"
killall openvpn
return 0
fi
fi

echo "ERROR: Failed to establish VPN connection"
killall openvpn
return 1
}

function install() {
# Install dependencies
apt update
apt install -y curl openvpn zenity

configure_vpn

# Test VPN connection
echo "Testing VPN connection..."
if ! timeout 30 openvpn --config netfree.ovpn --daemon; then
echo "VPN connection failed - aborting installation"
exit 1
fi

# Verify VPN IP
sleep 5
vpn_ip=$(ip addr show tun0 2>/dev/null | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
if [ "$vpn_ip" != "100.77.0.190" ]; then
echo "VPN connected but wrong IP ($vpn_ip) - aborting installation"
killall openvpn

exit 1
fi

killall openvpn

# Setup remaining components
mkdir -p /usr/share/tuxprotect/{res,vpn}
mkdir -p /var/log/tuxprotect
chmod 755 /var/log/tuxprotect

# Create VPN log directory
mkdir -p /var/log/tuxprotect/

# Create log directories with proper permissions
mkdir -p /var/log/tuxprotect
chmod 755 /var/log/tuxprotect
touch /var/log/tuxprotect/tuxprotect.log
touch /var/log/tuxprotect/vpn.log
chmod 644 /var/log/tuxprotect/*.log

# Setup log rotation configuration
cat > /etc/logrotate.d/tuxprotect << EOF
/var/log/tuxprotect/*.log {
weekly
rotate 4
compress
delaycompress
missingok
notifempty
create 644 root root
}
EOF

# ...existing code...

# Copy OpenVPN config

# ...existing code...

apt install zenity
chattr -i /usr/bin/tuxprotect
cp tuxprotect /usr/bin/tuxprotect
cp tuxprotectgui /usr/bin/tuxprotectgui
chmod +x /usr/bin/tuxprotect
chmod +x /usr/bin/tuxprotectgui
mkdir /usr/share/tuxprotect/
mkdir -p /usr/share/tuxprotect/vpn/
cp netfree.ovpn /usr/share/tuxprotect/vpn/
cp restartservices.sh /usr/share/tuxprotect/restartservices
cp notification.sh /usr/share/tuxprotect/notification
chmod +x /usr/share/tuxprotect/restartservices
chmod +x /usr/share/tuxprotect/notification
cp -r res /usr/share/tuxprotect/res/
bash /usr/bin/tuxprotect &
}

echo '
#######################################################
# #
# Tux Protect #
# #
#######################################################'

echo 'You are trying to install "Tux Protect".
WARNING!!! This script was tested only with Ubuntu 22.10 ! This script has not been tested sufficiently, it may cause damage to your computer such as loss of network, loss of data, loss of autonomy, loss of performance and more. No uninstall tool will be provided.
This script updates itself, its behavior is subject to change over time.
Do you agree anyway? If yes, write "I agree"'
echo '#######################################################'
read response

if [ "$response" = "I agree" ] || [ "$response" = "i agree" ]; then
if [[ $EUID -ne 0 ]]; then
echo "Error! You have tu run this script with root privilege, run sudo ./install.sh"
exit 1
else
install
fi
echo "Tux Protect was installed succesffuly ! You're now protected :)"
else
echo "The Script was not installed."
fi



0 comments on commit 93f572f

Please sign in to comment.