Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# here is files wich we want to exclude from the repository
.env
test.sh
test.sh
test_*.sh
*.tmp
*.log
10 changes: 3 additions & 7 deletions connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ read -r -p "Enter the remote server IP address: " remote_server
read -r -p "Enter the remote server username [$USER]: " remote_username
read -r -p "Enter the remote server port [22]: " remote_port
read -rs -p "Enter the remote server password: " remote_password
echo

remote_port=${remote_port:-22}
remote_username=${remote_username:-$USER}

# temporary hard-coded values for testing
# Import variables from .env file
# source "./.env"
# temporary hard-coded values for testing

echo "Checking if the proxy configuration file exists on the remote server"
if ! sshpass -p "$remote_password" ssh -p "$remote_port" "$remote_username"@"$remote_server" "[ -f /etc/apt/apt.conf.d/33proxy ]"; then
echo "Adding proxy configuration to the remote server's APT configuration"
Expand All @@ -31,7 +27,7 @@ echo "Connected to the remote server and created a remote port forwarding"

# Check if the Docker container is already running
echo "Checking if the Docker container with a Squid proxy server is already running"
if ! docker ps -q -f name=squid-proxy >/dev/null; then
if ! docker ps -q -f name=squid-proxy &>/dev/null; then
echo "Starting the Docker container with a Squid proxy server"
docker run -d --name squid-proxy -p 3128:3128 ubuntu/squid:latest
echo "Changing Squid configuration to allow all requests"
Expand All @@ -41,7 +37,7 @@ fi
echo "Proxy server: http://localhost:3128"

# stop the Docker container, remove the proxy config file from APT, and close the SSH connection
function cleanup() {
cleanup() {
echo
echo "Cleaning up and stopping the proxy server"
echo "Checking if the Docker container is running"
Expand Down