Skip to content

Instantly share code, notes, and snippets.

@MightyMirko
Last active June 9, 2022 09:12
Show Gist options
  • Select an option

  • Save MightyMirko/ac2950b5551d85dc2c32b7720de37511 to your computer and use it in GitHub Desktop.

Select an option

Save MightyMirko/ac2950b5551d85dc2c32b7720de37511 to your computer and use it in GitHub Desktop.

Revisions

  1. MightyMirko revised this gist Jun 9, 2022. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,19 @@
    # Mit diesem Skript werden die Proxy-Parameter für den notwendigen Internetzugang
    # an mehreren Stellen geschrieben. Das Passwort wird im Klartext innerhalb der VM gespeichert
    ##############
    # Beispiel-Ausführung
    # Die Datei muss in die VM kommen. Mit Mobaxterm ist dies ganz einfach. Per Upload in den sftp browser auf
    # linken seite oder senden per scp (secure shell copy).
    # Zum Dateipfad wechseln und die Datei ausführbar machen. Anschließend ausführen mit bash
    # cd ~/proxypass
    # chmod u+x proxypass
    # bash proxypass.sh
    # Eingabe der Loginnamen und Passwörter, jedes mal mit enter bestätigen
    # OK...OK...OK...OK...OK...
    # Fail sollte nicht kommen - bitte die Ausgabe untersuchen.

    # TODO: Musterausgabe an Skript hängen (ohne PW)
    ##############

    if [ "$1" ]
    then
  2. MightyMirko revised this gist Jun 9, 2022. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,14 @@
    #!/bin/bash

    ##############
    # Author: Mirko Matošin #
    # Date: 2022-06-06
    # Last Edit: 2022-06-09
    # Hosted as gists in Github
    # Mit diesem Skript werden die Proxy-Parameter für den notwendigen Internetzugang
    # an mehreren Stellen geschrieben. Das Passwort wird im Klartext innerhalb der VM gespeichert
    ##############

    if [ "$1" ]
    then
    testpart=$1
  3. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 16 additions and 6 deletions.
    22 changes: 16 additions & 6 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,9 @@ fi
    echo $testpart
    pvdir=$(pwd)

    printf "Hallo Liebe Tutorial-Teilnehmer, \n wir vom iRAS heißen euch herzlich willkommen.\n
    Mit diesem Skript werden die Proxy-Parameter für den notwendigen Internetzugang\n
    an mehreren Stellen geschrieben. Das Passwort wird im Klartext innerhalb der VM gespeichert"
    printf "Hallo Liebe Tutorial-Teilnehmer, wir vom iRAS heißen euch herzlich willkommen.
    Mit diesem Skript werden die Proxy-Parameter für den notwendigen Internetzugang
    an mehreren Stellen geschrieben. Das Passwort wird im Klartext innerhalb der VM gespeichert\n"



    @@ -48,6 +48,13 @@ if [ $testpart -eq 0 ] || [ $testpart -eq 99 ]; then
    echo ""
    fi

    if sudo hwclock --hctosys;then
    echo OK
    else
    echo FAIL
    printf "Uhrzeit passt nicht"
    exit 1
    fi


    #################
    @@ -139,16 +146,19 @@ if [ $testpart -eq 3 ] || [ $testpart -eq 99 ];then
    cd $dir1 || exit
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    else;then
    else
    if sudo mkdir -p $dir1; then
    pvdir=$(pwd)
    cd $dir1 || exit
    else; echo FAIL
    else
    echo FAIL
    fi

    if sudo touch http-proxy.conf; then
    echo OK
    echo -e $yaml | sudo tee -a http-proxy.conf
    else; echo FAIL
    else
    echo FAIL
    fi
    cd $pvdir || exit
    fi
  4. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 60 additions and 67 deletions.
    127 changes: 60 additions & 67 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    if [ $1 ]
    if [ "$1" ]
    then
    testpart=$1
    else
    @@ -9,92 +9,93 @@ fi
    echo $testpart
    pvdir=$(pwd)

    echo "Hallo Liebe Tutorial-Teilnehmer, \n
    wir vom iRAS heißen euch herzlich willkommen"

    echo "Mit diesem Skript werden die Proxy-Parameter für den notwendigen Internetzugang\n
    printf "Hallo Liebe Tutorial-Teilnehmer, \n wir vom iRAS heißen euch herzlich willkommen.\n
    Mit diesem Skript werden die Proxy-Parameter für den notwendigen Internetzugang\n
    an mehreren Stellen geschrieben. Das Passwort wird im Klartext innerhalb der VM gespeichert"



    #################
    # Abfrage der Daten
    #################
    read -p "Geben sie ihren Loginnamen ein:" user
    echo Hallo: $user
    printf 'Hallo:\t%s\n' "$user"
    read -p "Geben sie ihr IZ-Kürzel ein:" iz
    echo Hallo: $name
    read -p "Geben sie ihr Passwort ein:" pass
    echo Hallo: $name

    #################
    #Anlegen für Zugriff im Terminal
    #################
    if [ $testpart -eq 0 ] || [ $testpart -eq 99 ]
    then
    http_proxy=http://$iz:$pass@proxy.hs-karlsruhe.de:8888
    https_proxy=http://$iz:$pass@proxy.hs-karlsruhe.de:8888
    if [ $testpart -eq 0 ] || [ $testpart -eq 99 ]; then
    http_proxy=http://${iz}:${pass}@proxy.hs-karlsruhe.de:8888
    https_proxy=http://${iz}:${pass}@proxy.hs-karlsruhe.de:8888
    no_proxy="*.hs-karlsruhe.de, 193.196.64.0/18, localhost, 127.0.0.1, 10.0.0.0/8, 172.0.0.0/8"
    echo $http_proxy
    echo "$http_proxy"

    export http_proxy=\"$http_proxy\"
    export https_proxy=\"$https_proxy\"

    echo "export http_proxy=\"$http_proxy\"" | tee -a /home/$USER/.bashrc
    echo "export https_proxy=\"$https_proxy\"" | tee -a /home/$USER/.bashrc
    echo "export no_proxy=\"$no_proxy\"" | tee -a /home/$USER/.bashrc
    source /home/$USER/.bashrc
    echo "export http_proxy=\"$http_proxy\"" | tee -a /home/"$USER"/.bashrc
    echo "export https_proxy=\"$https_proxy\"" | tee -a /home/"$USER"/.bashrc
    echo "export no_proxy=\"$no_proxy\"" | tee -a /home/"$USER"/.bashrc
    source /home/"$USER"/.bashrc

    #################
    # Test
    #################
    echo "Aktuelle IP: "
    curl -k "https://ifconfig.me"
    echo ""
    #################
    # Test
    #################
    echo "Aktuelle IP: "
    curl -k https://ifconfig.me
    echo ""
    fi



    #################
    # Apt
    #################
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ];then
    apthttp="Acquire::http::Proxy ${http_proxy}; "
    apthttps="Acquire::https::Proxy ${http_proxy}; "

    if sudo test -w "/etc/apt/apt.conf";
    then
    echo $apthttp | sudo tee -a /etc/apt/apt.conf
    echo $apthttps | sudo tee -a /etc/apt/apt.conf
    if sudo test -w "/etc/apt/apt.conf";then
    echo "$apthttp" | sudo tee -a /etc/apt/apt.conf
    echo "$apthttps" | sudo tee -a /etc/apt/apt.conf
    else
    sudo touch /etc/apt/apt.conf
    echo $apthttp | sudo tee -a /etc/apt/apt.conf
    echo $apthttps | sudo tee -a /etc/apt/apt.conf
    echo "$apthttp" | sudo tee -a /etc/apt/apt.conf
    echo "$apthttps" | sudo tee -a /etc/apt/apt.conf
    fi

    #################
    # Test
    #################
    cat /etc/apt/apt.conf
    sudo apt update
    if [ $? -eq 0 ]; then

    if sudo apt update; then
    echo OK
    else
    else
    echo FAIL
    exit 1
    fi

    fi
    fi

    printf "\n\n######################################\n\n"
    echo ok

    #################
    # Container runtime
    #################
    if [ $testpart -eq 2 ] || [ $testpart -eq 99 ]
    then
    sudo apt install jq -y && echo SUCCESS || echo FAIL
    if [ $? -eq 0 ];
    then
    if sudo apt install jq -y; then
    echo OK
    key1=default
    subkey1=httpProxy
    subkey2=httpsProxy
    subkey3=noProxy
    dockprox=$(jq -n --arg key1 "$key1" --arg subkey1 "$subkey1" --arg subkey2 "$subkey2" --arg subkey3 "$subkey3" --arg value1 "$http_proxy" --arg value2 "$https_proxy" --arg value3 "$no_proxy" '
    dockprox=$(jq -n --arg key1 "$key1" --arg subkey1 "$subkey1" --arg subkey2 "$subkey2" --arg subkey3 "$subkey3" \
    --arg value1 "$http_proxy" --arg value2 "$https_proxy" --arg value3 "$no_proxy" '
    { proxies:{
    ($key1): {
    ($subkey1): $value1,
    @@ -105,11 +106,11 @@ then
    }
    ')
    echo $dockprox
    # Ist die config.json beschreibbar?
    # Ist die config.json beschreibbar

    if [ -w ~/.docker/config.json ]
    then
    echo $dockprox | tee -a ~/.docker/config.json

    elif [ ! -d ~/.docker/ ]
    then
    mkdir -p ~/.docker/
    @@ -122,32 +123,35 @@ then

    fi
    fi


    #################
    # Docker daemon
    #################
    if [ $testpart -eq 3 ] || [ $testpart -eq 99 ]
    then
    if [ $testpart -eq 3 ] || [ $testpart -eq 99 ];then
    if [ $? -eq 0 ]; then
    echo OK
    dir1="/etc/systemd/system/docker.service.d"
    yaml="[Service]\nEnvironment="HTTP_PROXY=$http_proxy"\nEnvironment="HTTPS_PROXY=$https_proxy"\nEnvironment="NO_PROXY=$no_proxy""
    # Ist der Ordner da?
    if [ -d $dir1 ]
    then
    pvdir=$(pwd)
    cd $dir1
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    elif [ ! -d $dir1 ]
    then
    sudo mkdir -p $dir1
    if [ -d $dir1 ];then
    pvdir=$(pwd)
    cd $dir1
    cd $dir1 || exit
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    cd $pvdir
    else;then
    if sudo mkdir -p $dir1; then
    pvdir=$(pwd)
    cd $dir1 || exit
    else; echo FAIL
    fi
    if sudo touch http-proxy.conf; then
    echo OK
    echo -e $yaml | sudo tee -a http-proxy.conf
    else; echo FAIL
    fi
    cd $pvdir || exit
    fi

    else
    echo FAIL
    fi
    @@ -173,15 +177,4 @@ fi




    exit_script()
    {
    status=$?
    if [[ $status -eq 0 ]] ; then
    echo "exit from script with success"
    else
    echo "exit with error..."
    fi >&2
    # Now you can just make one, all-purpose call to exit
    exit $status
    }
    exit 0
  5. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -75,6 +75,7 @@ then
    echo OK
    else
    echo FAIL
    exit 1

    fi
    fi
    @@ -154,14 +155,25 @@ fi

    sudo apt install git -y
    if [ $? -eq 0 ]; then
    echo OK
    echo "alles ist gut durchgelaufen"
    git config --global http.proxy $http_proxy
    git config --global https.proxy $https_proxy
    git config --global http.https://www.w.hs-karlsruhe.de.proxy ""
    if [ $? -eq 0 ]; then
    echo OK
    exit 0
    else
    echo FAIL
    exit 1
    fi
    else
    echo "FAIL git install.. no git config"
    exit 1
    fi




    exit_script()
    {
    status=$?
  6. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 86 additions and 55 deletions.
    141 changes: 86 additions & 55 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -33,18 +33,20 @@ then
    https_proxy=http://$iz:$pass@proxy.hs-karlsruhe.de:8888
    no_proxy="*.hs-karlsruhe.de, 193.196.64.0/18, localhost, 127.0.0.1, 10.0.0.0/8, 172.0.0.0/8"
    echo $http_proxy

    export http_proxy=\"$http_proxy\"
    export https_proxy=\"$https_proxy\"

    echo "export http_proxy=\"$http_proxy\"" | tee -a /home/$USER/.bashrc
    echo "export https_proxy=\"$https_proxy\"" | tee -a /home/$USER/.bashrc
    echo "export no_proxy=\"$no_proxy\"" | tee -a /home/$USER/.bashrc

    source /home/$USER/.bashrc

    #################
    # Test
    #################
    echo "Aktuelle IP: "
    curl -k https://ifconfig.me
    curl -k "https://ifconfig.me"
    echo ""
    fi
    #################
    @@ -53,10 +55,8 @@ fi
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    apthttp="Acquire::http::Proxy ${http_proxy}; "

    apthttps="Acquire::https::Proxy ${http_proxy}; "


    if sudo test -w "/etc/apt/apt.conf";
    then
    echo $apthttp | sudo tee -a /etc/apt/apt.conf
    @@ -71,74 +71,105 @@ then
    #################
    cat /etc/apt/apt.conf
    sudo apt update
    if [ $? -eq 0 ]; then
    echo OK
    else
    echo FAIL

    fi
    fi


    #################
    # Container runtime
    #################
    if [ $testpart -eq 2 ] || [ $testpart -eq 99 ]
    then
    sudo apt install jq -y

    key1=default
    subkey1=httpProxy
    subkey2=httpsProxy
    subkey3=noProxy
    dockprox=$(jq -n --arg key1 "$key1" --arg subkey1 "$subkey1" --arg subkey2 "$subkey2" --arg subkey3 "$subkey3" --arg value1 "$http_proxy" --arg value2 "$https_proxy" --arg value3 "$no_proxy" '
    { proxies:{
    ($key1): {
    ($subkey1): $value1,
    ($subkey2): $value2,
    ($subkey3): $value3
    }
    }
    }
    ')


    echo $dockprox
    if [ -w ~/.docker/config.json ]
    sudo apt install jq -y && echo SUCCESS || echo FAIL
    if [ $? -eq 0 ];
    then
    echo $dockprox | tee -a ~/.docker/config.json
    echo OK
    key1=default
    subkey1=httpProxy
    subkey2=httpsProxy
    subkey3=noProxy
    dockprox=$(jq -n --arg key1 "$key1" --arg subkey1 "$subkey1" --arg subkey2 "$subkey2" --arg subkey3 "$subkey3" --arg value1 "$http_proxy" --arg value2 "$https_proxy" --arg value3 "$no_proxy" '
    { proxies:{
    ($key1): {
    ($subkey1): $value1,
    ($subkey2): $value2,
    ($subkey3): $value3
    }
    }
    }
    ')
    echo $dockprox
    # Ist die config.json beschreibbar?
    if [ -w ~/.docker/config.json ]
    then
    echo $dockprox | tee -a ~/.docker/config.json

    elif [ ! -d ~/.docker/ ]
    then
    mkdir -p ~/.docker/
    touch ~/.docker/config.json
    echo $dockprox | tee -a ~/.docker/config.json
    else
    touch ~/.docker/config.json
    echo $dockprox | tee -a ~/.docker/config.json
    elif [ ! -d ~/.docker/ ]
    then
    mkdir -p ~/.docker/
    touch ~/.docker/config.json
    echo $dockprox | tee -a ~/.docker/config.json
    else
    touch ~/.docker/config.json
    echo $dockprox | tee -a ~/.docker/config.json
    fi

    fi
    fi
    #################
    # Docker daemon
    #################
    if [ $testpart -eq 3 ] || [ $testpart -eq 99 ]
    then
    dir1="/etc/systemd/system/docker.service.d"
    yaml="[Service]\nEnvironment="HTTP_PROXY=$http_proxy"\nEnvironment="HTTPS_PROXY=$https_proxy"\nEnvironment="NO_PROXY=$no_proxy""
    if [ -d $dir1 ]
    then
    pvdir=$(pwd)
    cd $dir1
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    elif [ ! -d $dir1 ]
    then
    sudo mkdir -p $dir1
    pvdir=$(pwd)
    cd $dir1
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    cd $pvdir
    if [ $? -eq 0 ]; then
    echo OK
    dir1="/etc/systemd/system/docker.service.d"
    yaml="[Service]\nEnvironment="HTTP_PROXY=$http_proxy"\nEnvironment="HTTPS_PROXY=$https_proxy"\nEnvironment="NO_PROXY=$no_proxy""
    # Ist der Ordner da?
    if [ -d $dir1 ]
    then
    pvdir=$(pwd)
    cd $dir1
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    elif [ ! -d $dir1 ]
    then
    sudo mkdir -p $dir1
    pvdir=$(pwd)
    cd $dir1
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    cd $pvdir
    fi

    else
    echo FAIL
    fi
    fi

    sudo apt install git -y
    if [ $? -eq 0 ]; then
    echo OK
    git config --global http.proxy $http_proxy
    git config --global https.proxy $https_proxy
    git config --global http.https://www.w.hs-karlsruhe.de.proxy ""
    else
    echo "FAIL git install.. no git config"
    fi

    git config --global http.proxy $http_proxy
    git config --global https.proxy $https_proxy
    git config --global http.https://www.w.hs-karlsruhe.de.proxy ""



    exit_script()
    {
    status=$?
    if [[ $status -eq 0 ]] ; then
    echo "exit from script with success"
    else
    echo "exit with error..."
    fi >&2
    # Now you can just make one, all-purpose call to exit
    exit $status
    }
  7. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -134,7 +134,7 @@ then
    fi
    fi

    sudo apt install git -yaml
    sudo apt install git -y

    git config --global http.proxy $http_proxy
    git config --global https.proxy $https_proxy
  8. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -52,9 +52,9 @@ fi
    #################
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    apthttp="Acquire::http::Proxy \"${http_proxy}\"; "
    apthttp="Acquire::http::Proxy ${http_proxy}; "

    apthttps="Acquire::https::Proxy \"${http_proxy}\"; "
    apthttps="Acquire::https::Proxy ${http_proxy}; "


    if sudo test -w "/etc/apt/apt.conf";
  9. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -57,9 +57,6 @@ then
    apthttps="Acquire::https::Proxy \"${http_proxy}\"; "


    echo "Das wird in apt.conf eingetragen: $apthttp"
    echo "Das wird in apt.conf eingetragen: $apthttps"

    if sudo test -w "/etc/apt/apt.conf";
    then
    echo $apthttp | sudo tee -a /etc/apt/apt.conf
  10. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -52,9 +52,9 @@ fi
    #################
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    apthttp="Acquire::http::Proxy \"$http_proxy\"; "
    apthttp="Acquire::http::Proxy \"${http_proxy}\"; "

    apthttps="Acquire::https::Proxy \"$http_proxy\"; "
    apthttps="Acquire::https::Proxy \"${http_proxy}\"; "


    echo "Das wird in apt.conf eingetragen: $apthttp"
  11. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -55,6 +55,8 @@ then
    apthttp="Acquire::http::Proxy \"$http_proxy\"; "

    apthttps="Acquire::https::Proxy \"$http_proxy\"; "


    echo "Das wird in apt.conf eingetragen: $apthttp"
    echo "Das wird in apt.conf eingetragen: $apthttps"

    @@ -70,6 +72,7 @@ then
    #################
    # Test
    #################
    cat /etc/apt/apt.conf
    sudo apt update
    fi
    #################
  12. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,8 @@ fi
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    apthttp="Acquire::http::Proxy \"$http_proxy\"; "
    apthttps="Acquire::https::Proxy" \"$http_proxy\"; "

    apthttps="Acquire::https::Proxy \"$http_proxy\"; "
    echo "Das wird in apt.conf eingetragen: $apthttp"
    echo "Das wird in apt.conf eingetragen: $apthttps"

  13. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -52,8 +52,8 @@ fi
    #################
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    apthttp="Acquire::http::Proxy \"$http_proxy\";
    apthttps="Acquire::https::Proxy \"$http_proxy\";
    apthttp="Acquire::http::Proxy \"$http_proxy\"; "
    apthttps="Acquire::https::Proxy" \"$http_proxy\"; "
    echo "Das wird in apt.conf eingetragen: $apthttp"
    echo "Das wird in apt.conf eingetragen: $apthttps"
  14. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -52,8 +52,8 @@ fi
    #################
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    apthttp="Acquire::http::Proxy \"$http_proxy\";"
    apthttps="Acquire::https::Proxy \"$http_proxy\";"
    apthttp="Acquire::http::Proxy \"$http_proxy\";
    apthttps="Acquire::https::Proxy \"$http_proxy\";
    echo "Das wird in apt.conf eingetragen: $apthttp"
    echo "Das wird in apt.conf eingetragen: $apthttps"

  15. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -137,6 +137,7 @@ sudo apt install git -yaml

    git config --global http.proxy $http_proxy
    git config --global https.proxy $https_proxy
    git config --global http.https://www.w.hs-karlsruhe.de.proxy ""



  16. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -133,6 +133,10 @@ then
    fi
    fi

    sudo apt install git -yaml

    git config --global http.proxy $http_proxy
    git config --global https.proxy $https_proxy



  17. MightyMirko revised this gist Jun 7, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -94,7 +94,7 @@ then
    ')


    echo $dockprox
    echo $dockprox
    if [ -w ~/.docker/config.json ]
    then
    echo $dockprox | tee -a ~/.docker/config.json
  18. Mirko Matosin revised this gist Jun 7, 2022. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -93,7 +93,8 @@ then
    }
    ')

    echo $dockprox

    echo $dockprox
    if [ -w ~/.docker/config.json ]
    then
    echo $dockprox | tee -a ~/.docker/config.json
    @@ -102,12 +103,10 @@ then
    then
    mkdir -p ~/.docker/
    touch ~/.docker/config.json
    echo $apthttp | tee -a ~/.docker/config.json
    echo $apthttps | tee -a ~/.docker/config.json
    echo $dockprox | tee -a ~/.docker/config.json
    else
    touch ~/.docker/config.json
    echo $apthttp | tee -a ~/.docker/config.json
    echo $apthttps | tee -a ~/.docker/config.json
    echo $dockprox | tee -a ~/.docker/config.json
    fi
    fi
    #################
  19. MightyMirko created this gist Jun 6, 2022.
    139 changes: 139 additions & 0 deletions proxypass-distributor.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,139 @@
    #!/bin/bash

    if [ $1 ]
    then
    testpart=$1
    else
    testpart=99
    fi
    echo $testpart
    pvdir=$(pwd)

    echo "Hallo Liebe Tutorial-Teilnehmer, \n
    wir vom iRAS heißen euch herzlich willkommen"

    echo "Mit diesem Skript werden die Proxy-Parameter für den notwendigen Internetzugang\n
    an mehreren Stellen geschrieben. Das Passwort wird im Klartext innerhalb der VM gespeichert"

    #################
    # Abfrage der Daten
    #################
    read -p "Geben sie ihren Loginnamen ein:" user
    echo Hallo: $user
    read -p "Geben sie ihr IZ-Kürzel ein:" iz
    echo Hallo: $name
    read -p "Geben sie ihr Passwort ein:" pass
    echo Hallo: $name
    #################
    #Anlegen für Zugriff im Terminal
    #################
    if [ $testpart -eq 0 ] || [ $testpart -eq 99 ]
    then
    http_proxy=http://$iz:$pass@proxy.hs-karlsruhe.de:8888
    https_proxy=http://$iz:$pass@proxy.hs-karlsruhe.de:8888
    no_proxy="*.hs-karlsruhe.de, 193.196.64.0/18, localhost, 127.0.0.1, 10.0.0.0/8, 172.0.0.0/8"
    echo $http_proxy
    export http_proxy=\"$http_proxy\"
    export https_proxy=\"$https_proxy\"

    echo "export http_proxy=\"$http_proxy\"" | tee -a /home/$USER/.bashrc
    echo "export https_proxy=\"$https_proxy\"" | tee -a /home/$USER/.bashrc
    echo "export no_proxy=\"$no_proxy\"" | tee -a /home/$USER/.bashrc

    #################
    # Test
    #################
    echo "Aktuelle IP: "
    curl -k https://ifconfig.me
    echo ""
    fi
    #################
    # Apt
    #################
    if [ $testpart -eq 1 ] || [ $testpart -eq 99 ]
    then
    apthttp="Acquire::http::Proxy \"$http_proxy\";"
    apthttps="Acquire::https::Proxy \"$http_proxy\";"
    echo "Das wird in apt.conf eingetragen: $apthttp"
    echo "Das wird in apt.conf eingetragen: $apthttps"

    if sudo test -w "/etc/apt/apt.conf";
    then
    echo $apthttp | sudo tee -a /etc/apt/apt.conf
    echo $apthttps | sudo tee -a /etc/apt/apt.conf
    else
    sudo touch /etc/apt/apt.conf
    echo $apthttp | sudo tee -a /etc/apt/apt.conf
    echo $apthttps | sudo tee -a /etc/apt/apt.conf
    fi
    #################
    # Test
    #################
    sudo apt update
    fi
    #################
    # Container runtime
    #################
    if [ $testpart -eq 2 ] || [ $testpart -eq 99 ]
    then
    sudo apt install jq -y

    key1=default
    subkey1=httpProxy
    subkey2=httpsProxy
    subkey3=noProxy
    dockprox=$(jq -n --arg key1 "$key1" --arg subkey1 "$subkey1" --arg subkey2 "$subkey2" --arg subkey3 "$subkey3" --arg value1 "$http_proxy" --arg value2 "$https_proxy" --arg value3 "$no_proxy" '
    { proxies:{
    ($key1): {
    ($subkey1): $value1,
    ($subkey2): $value2,
    ($subkey3): $value3
    }
    }
    }
    ')

    echo $dockprox
    if [ -w ~/.docker/config.json ]
    then
    echo $dockprox | tee -a ~/.docker/config.json

    elif [ ! -d ~/.docker/ ]
    then
    mkdir -p ~/.docker/
    touch ~/.docker/config.json
    echo $apthttp | tee -a ~/.docker/config.json
    echo $apthttps | tee -a ~/.docker/config.json
    else
    touch ~/.docker/config.json
    echo $apthttp | tee -a ~/.docker/config.json
    echo $apthttps | tee -a ~/.docker/config.json
    fi
    fi
    #################
    # Docker daemon
    #################
    if [ $testpart -eq 3 ] || [ $testpart -eq 99 ]
    then
    dir1="/etc/systemd/system/docker.service.d"
    yaml="[Service]\nEnvironment="HTTP_PROXY=$http_proxy"\nEnvironment="HTTPS_PROXY=$https_proxy"\nEnvironment="NO_PROXY=$no_proxy""
    if [ -d $dir1 ]
    then
    pvdir=$(pwd)
    cd $dir1
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    elif [ ! -d $dir1 ]
    then
    sudo mkdir -p $dir1
    pvdir=$(pwd)
    cd $dir1
    sudo touch http-proxy.conf
    echo -e $yaml | sudo tee -a http-proxy.conf
    cd $pvdir
    fi
    fi