Skip to content

Instantly share code, notes, and snippets.

@atiris
Last active September 8, 2023 13:01
Show Gist options
  • Save atiris/34dc670264274b3a472f2a718e4de83a to your computer and use it in GitHub Desktop.
Save atiris/34dc670264274b3a472f2a718e4de83a to your computer and use it in GitHub Desktop.

Revisions

  1. atiris revised this gist Jan 6, 2020. 1 changed file with 24 additions and 7 deletions.
    31 changes: 24 additions & 7 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,7 @@ else
    fi

    if [[ $response =~ ^(yes|y) ]]; then
    # original java first
    echo "-----BEGIN PGP PUBLIC KEY BLOCK-----
    Version: SKS 1.1.5
    Comment: Hostname: keyserver.ubuntu.com
    @@ -75,16 +76,28 @@ xTdyLkFCrbbIAZEHtmjXRgQu3VUcSkgHMdn46j/7N9qtZUcXQ0TOsZUJRANY/eHsBvUg1cBm
    echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
    echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
    echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list

    apt-get update
    apt-get install -f
    echo -e "$NC""Remove source with: rm /etc/apt/sources.list.d/webupd8team-java.list"

    apt update
    apt install -f
    dpkg --configure -a
    apt-get install -y oracle-java8-installer
    apt install -y oracle-java8-installer

    apt-get install -y oracle-java8-set-default
    apt install -y oracle-java8-set-default

    echo ""
    echo -e "$GREEN""Java installation is complete.""$NC"
    echo -e "$GREEN""Java installation script is complete... Testing.""$NC"
    JAVA_VERSION_LOCAL=`echo $(java -version 2>&1)| awk -F \" '{print $2}'`
    if [[ $JAVA_VERSION_LOCAL = *[!\ ]* ]]; then
    echo "Actual java vesion on your system is:"
    java -version
    else
    # alternative java installer
    echo -e "$RED""First attempt failed! I am trying to install the openjdk version...""$NC"
    apt install -y openjdk-8-jdk

    echo -e "$GREEN""Java installation script is complete, again... Testing.""$NC"
    fi
    else
    echo "Java installation skipped."
    fi
    @@ -98,9 +111,13 @@ else
    echo "There is probably a new version of java and the installer wasn't yet updated to reference it."
    echo -e "$GREEN""You can do this steps to install java manually:""$NC"
    echo ""
    echo "Check if your system supports openjdk alternative and use it."
    echo ""
    echo "Or harder way:"
    echo "Open oracle download site https://www.oracle.com/technetwork/java/javase/downloads/index.html"
    echo "Find Java SE 8 link, accept license and select jdk-8uXXX-linux-arm32-vfp-hflt.tar.gz version"
    echo "Download it to any directory and unpack with command:"
    echo "Download it (version 8 is not supported, so you need to have an oracle account)"
    echo "to any directory and unpack with command:"
    echo -e "$BLUE""tar -xzf jdk-8uXXX-linux-arm32-vfp-hflt.tar.gz""$NC"
    echo "Create /usr/local/java directory mkdir -p -v /usr/local/java"
    echo "Move unpacked to /usr/local/java/jdk1.8.0_XXX:"
  2. atiris revised this gist Feb 27, 2019. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -270,7 +270,7 @@ Description=JDownloader2 headless service
    After=network.target
    [Service]
    User=""$RUN_AS_USER""
    # User=""$RUN_AS_USER"" # not all jDownloader services working with non root user
    Type=simple
    Environment=JD_HOME=/opt/JDownloader
    WorkingDirectory=/opt/JDownloader
    @@ -300,6 +300,11 @@ WantedBy=multi-user.target
    echo ""
    echo -e "$GREEN""Service installation is complete.""$NC"
    echo "You can check service status with: systemctl status jdownloader"
    echo "Sometimes jDownloader create file or directory with root owner rights"
    echo "To fix it you can crate cron job:"
    echo "sudo crontab -u root -e"
    echo "And run chow for your user (osmc) on your requested directory like this:"
    echo "*/5 * * * * sudo chown -R osmc:osmc /home/osmc/Download >/dev/null 2>&1"
    else
    echo -e "$RED""ERROR! I can not create a service.""$NC"
    fi
  3. atiris revised this gist Feb 26, 2019. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -206,6 +206,18 @@ if [[ $response =~ ^(yes|y) ]]; then
    fi
    done
    echo -e "$GREEN""JDownloader instalation is complete.""$NC"

    echo ""
    echo -e "$GREEN""Note about download youtube videos""$NC"
    echo ""
    echo "To download youtube videos you need to install ffmpeg"
    echo "You can build it yourself or use static build. For static build:"
    echo "Download armhf version from johnvansickle.com/ffmpeg"
    echo -e "$BLUE""wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-armhf-static.tar.xz""$NC"
    echo "Extract it anywhere"
    echo -e "$BLUE""tar -xvf ffmpeg-release-armhf-static.tar.xz""$NC"
    echo "And set 2 paths to ffmpeg binaries in advanced settings of selected jDownloader"
    echo "You can use my.jdownloader for this, go to settings, advanced and search for 'ffmpeg path'"
    else
    echo "JDownloader installation skipped."
    fi
  4. atiris revised this gist Feb 26, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -115,10 +115,10 @@ else
    echo -e "$RED""Continue anyway?""$NC"
    read -p "[y/N] " response
    response=${response,,}
    fi

    if [[ $response =~ ^(no|n) ]]; then
    exit 0
    if [[ $response =~ ^(no|n) ]]; then
    exit 0
    fi
    fi

    echo ""
  5. atiris revised this gist Feb 4, 2019. No changes.
  6. atiris revised this gist Feb 4, 2019. No changes.
  7. atiris revised this gist Feb 4, 2019. No changes.
  8. atiris revised this gist Feb 4, 2019. 1 changed file with 23 additions and 25 deletions.
    48 changes: 23 additions & 25 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,8 @@ if [[ "$EUID" -ne 0 ]]; then
    return
    fi

    RUN_AS_USER=root

    # Colors
    NC='\033[0m'
    RED='\033[0;91m'
    @@ -151,7 +153,6 @@ if [[ $response =~ ^(yes|y) ]]; then
    echo -e "$GREEN""OK""$NC"
    echo ""

    RUN_AS_USER=root
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u osmc 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Install JDownloader with 'osmc' user rights."
    RUN_AS_USER=osmc
    @@ -229,30 +230,27 @@ if [[ $response =~ ^(yes|y) ]]; then
    echo ""
    touch /opt/JDownloader/JDownloader.pid

    if [[ "$RUN_AS_USER" == '' ]]; then
    RUN_AS_USER=root
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u osmc 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Using 'osmc' user rights."
    RUN_AS_USER=osmc
    fi
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u pi 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Using 'pi' user rights."
    RUN_AS_USER=pi
    fi
    if [ "$RUN_AS_USER" == 'root' ]; then
    echo "Running service as 'root'?"
    echo "Running JDownloader under 'root' user is not recommended."
    response=xxxundefinedxxx
    echo ""
    echo -e "$RED""Can you type another user name?""$NC"
    read -p "Username " response
    response=${response,,}
    if [[ $response =~ ^(xxxundefinedxxx) ]]; then
    echo "Well, ok then, I'll use 'root' for JDownloader service."
    else
    echo "JDownloader will be run with $response rights."
    RUN_AS_USER=$response
    fi
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u osmc 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Using 'osmc' user rights."
    RUN_AS_USER=osmc
    fi
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u pi 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Using 'pi' user rights."
    RUN_AS_USER=pi
    fi
    if [ "$RUN_AS_USER" == 'root' ]; then
    echo "You want to start the service as 'root' user?"
    echo "Running JDownloader under 'root' user is not recommended."
    response=xxxundefinedxxx
    echo ""
    echo -e "$RED""Can you type another user name?""$NC"
    read -p "Username " response
    response=${response,,}
    if [[ $response =~ ^(xxxundefinedxxx) ]]; then
    echo "Well, ok then, I'll use 'root' for JDownloader service."
    else
    echo "JDownloader will be run with $response rights."
    RUN_AS_USER=$response
    fi
    fi
    echo "[Unit]
  9. atiris revised this gist Feb 4, 2019. 1 changed file with 41 additions and 2 deletions.
    43 changes: 41 additions & 2 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -161,7 +161,19 @@ if [[ $response =~ ^(yes|y) ]]; then
    RUN_AS_USER=pi
    fi
    if [ "$RUN_AS_USER" == 'root' ]; then
    echo "Installing as 'root'."
    echo "Installing as 'root'?"
    echo "Running JDownloader under 'root' user is not recommended."
    response=xxxundefinedxxx
    echo ""
    echo -e "$RED""Can you type another user name?""$NC"
    read -p "Username " response
    response=${response,,}
    if [[ $response =~ ^(xxxundefinedxxx) ]]; then
    echo "Well, ok then, I'll use 'root' for JDownloader."
    else
    echo "JDownloader will be run with $response rights."
    RUN_AS_USER=$response
    fi
    fi

    if [ ! -d /opt/JDownloader ]; then
    @@ -217,13 +229,40 @@ if [[ $response =~ ^(yes|y) ]]; then
    echo ""
    touch /opt/JDownloader/JDownloader.pid

    if [[ "$RUN_AS_USER" == '' ]]; then
    RUN_AS_USER=root
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u osmc 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Using 'osmc' user rights."
    RUN_AS_USER=osmc
    fi
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u pi 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Using 'pi' user rights."
    RUN_AS_USER=pi
    fi
    if [ "$RUN_AS_USER" == 'root' ]; then
    echo "Running service as 'root'?"
    echo "Running JDownloader under 'root' user is not recommended."
    response=xxxundefinedxxx
    echo ""
    echo -e "$RED""Can you type another user name?""$NC"
    read -p "Username " response
    response=${response,,}
    if [[ $response =~ ^(xxxundefinedxxx) ]]; then
    echo "Well, ok then, I'll use 'root' for JDownloader service."
    else
    echo "JDownloader will be run with $response rights."
    RUN_AS_USER=$response
    fi
    fi
    fi
    echo "[Unit]
    Description=JDownloader2 headless service
    After=network.target
    [Service]
    Environment=JD_HOME=/opt/JDownloader
    User=""$RUN_AS_USER""
    Type=simple
    Environment=JD_HOME=/opt/JDownloader
    WorkingDirectory=/opt/JDownloader
    ExecStart=/usr/bin/java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar
    RemainAfterExit=yes
  10. atiris revised this gist Jan 16, 2019. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # Script: osmc-java-jdownloader-installer.sh
    # Author: Jozef Pažin
    # Description: Wizard to install the current version of jdownloader on raspberry pi running osmc kodi.
    # Description: Wizard to install the current version of java and/or jdownloader on raspberry pi running osmc.
    # License: MIT | use arbitrarily, attribution is not required
    # How to run:
    # - Check if this code is correct first because this script need to be run under root and run gist
    @@ -92,8 +92,9 @@ if [[ $JAVA_VERSION_LOCAL = *[!\ ]* ]]; then
    echo "Actual java vesion on your system is:"
    java -version
    else
    echo -e "$RED""Java is still not installed!"
    echo -e "$GREEN"" You can do this steps:""$NC"
    echo -e "$RED""Java is still not installed!""$NC"
    echo "There is probably a new version of java and the installer wasn't yet updated to reference it."
    echo -e "$GREEN""You can do this steps to install java manually:""$NC"
    echo ""
    echo "Open oracle download site https://www.oracle.com/technetwork/java/javase/downloads/index.html"
    echo "Find Java SE 8 link, accept license and select jdk-8uXXX-linux-arm32-vfp-hflt.tar.gz version"
  11. atiris revised this gist Jan 15, 2019. 1 changed file with 30 additions and 1 deletion.
    31 changes: 30 additions & 1 deletion osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -83,10 +83,39 @@ xTdyLkFCrbbIAZEHtmjXRgQu3VUcSkgHMdn46j/7N9qtZUcXQ0TOsZUJRANY/eHsBvUg1cBm

    echo ""
    echo -e "$GREEN""Java installation is complete.""$NC"
    else
    echo "Java installation skipped."
    fi

    JAVA_VERSION_LOCAL=`echo $(java -version 2>&1)| awk -F \" '{print $2}'`
    if [[ $JAVA_VERSION_LOCAL = *[!\ ]* ]]; then
    echo "Actual java vesion on your system is:"
    java -version
    else
    echo "Java installation skipped."
    echo -e "$RED""Java is still not installed!"
    echo -e "$GREEN"" You can do this steps:""$NC"
    echo ""
    echo "Open oracle download site https://www.oracle.com/technetwork/java/javase/downloads/index.html"
    echo "Find Java SE 8 link, accept license and select jdk-8uXXX-linux-arm32-vfp-hflt.tar.gz version"
    echo "Download it to any directory and unpack with command:"
    echo -e "$BLUE""tar -xzf jdk-8uXXX-linux-arm32-vfp-hflt.tar.gz""$NC"
    echo "Create /usr/local/java directory mkdir -p -v /usr/local/java"
    echo "Move unpacked to /usr/local/java/jdk1.8.0_XXX:"
    echo -e "$BLUE""mv /path/to/jdk1.8.0_XXX /usr/local/java/jdk1.8.0_XXX""$NC"
    echo "Update java alternatives with new path:"
    echo -e "$BLUE""sudo update-alternatives --install \"/usr/bin/java\" \"java\" \"/usr/local/java/jdk1.8.0_XXX/bin/java\" 1""$NC"
    echo "Set default java with:"
    echo -e "$BLUE""sudo update-alternatives --set java /usr/local/java/jdk1.8.0_XXX/bin/java""$NC"

    response=n
    echo ""
    echo -e "$RED""Continue anyway?""$NC"
    read -p "[y/N] " response
    response=${response,,}
    fi

    if [[ $response =~ ^(no|n) ]]; then
    exit 0
    fi

    echo ""
  12. atiris revised this gist Jun 8, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -188,13 +188,15 @@ if [[ $response =~ ^(yes|y) ]]; then
    touch /opt/JDownloader/JDownloader.pid

    echo "[Unit]
    Description=JDownloader2 headless server daemon with autorestart.
    Description=JDownloader2 headless service
    After=network.target
    [Service]
    Environment=JD_HOME=/opt/JDownloader
    Type=simple
    WorkingDirectory=/opt/JDownloader
    ExecStart=/usr/bin/java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar
    RemainAfterExit=yes
    Restart=on-failure
    RestartSec=10s
  13. atiris revised this gist Jun 5, 2018. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -192,10 +192,9 @@ Description=JDownloader2 headless server daemon with autorestart.
    After=network.target
    [Service]
    Environment='DIR=/opt/JDownloader'
    Type=simple
    WorkingDirectory=\${DIR}
    ExecStart=/usr/bin/java -Djava.awt.headless=true -jar \${DIR}/JDownloader.jar
    WorkingDirectory=/opt/JDownloader
    ExecStart=/usr/bin/java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar
    Restart=on-failure
    RestartSec=10s
  14. atiris revised this gist Jun 3, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -116,8 +116,9 @@ if [[ $response =~ ^(yes|y) ]]; then
    echo "You can continue in next step with installation of daemon,"
    echo "to start JDownloader automatically on reboot or after crash."
    echo -e "$NC"
    echo "Press enter to OK"
    echo "Press enter to continue"
    read
    echo -e "$GREEN""OK""$NC"
    echo ""

    RUN_AS_USER=root
    @@ -178,7 +179,7 @@ if [ -e /etc/systemd/system/jdownloader.service ]; then
    read -p "[y/N] " response
    response=${response,,}
    else
    echo -e "$YELLOW""Service for jdownloader not exists yet.""$GREEN""No worries, I will create it.""$NC"
    echo -e "$YELLOW""Service for jdownloader not exists yet.""$GREEN"" No worries, I will create it.""$NC"
    response=y
    fi

  15. atiris revised this gist Jun 1, 2018. No changes.
  16. atiris revised this gist Jun 1, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@
    # Description: Wizard to install the current version of jdownloader on raspberry pi running osmc kodi.
    # License: MIT | use arbitrarily, attribution is not required
    # How to run:
    # - Check it first if this code is correct because this script need to be run under root
    # and run gist from web is not recommended procedure in terms of security
    # https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a
    # - Check if this code is correct first because this script need to be run under root and run gist
    # from web is not recommended in terms of security only that you know exactly what it does. Check it:
    # curl -Ls https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | nano -
    # - And then run it with command (this way support 'read' user inputs):
    #
    # SCRIPT=`curl -Ls https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw`; sudo bash -c "$SCRIPT"
  17. atiris revised this gist May 31, 2018. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,15 @@
    # Script: osmc-java-jdownloader-installer.sh
    # Author: Jozef Pažin
    # Description: Wizard to install the current version of jdownloader on raspberry pi running osmc kodi.
    # License: MIT
    # License: MIT | use arbitrarily, attribution is not required
    # How to run:
    # - Check it first if this code is correct because this script need to be run under root
    # and run gist from web is not recommended procedure in terms of security
    # https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a
    # - And then run it:
    # SCRIPT=`curl -Ls https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw`; sudo bash -c "$SCRIPT"
    # - And then run it with command (this way support 'read' user inputs):
    #
    # SCRIPT=`curl -Ls https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw`; sudo bash -c "$SCRIPT"
    #
    # Inspiration:
    # - https://gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f
    # - https://github.com/PlusMinus0/headless-jd2-docker
  18. atiris revised this gist May 30, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -207,7 +207,7 @@ WantedBy=multi-user.target
    echo -e "Service jdownloader enabled > ""$GREEN""OK""$NC"
    systemctl start jdownloader

    SERVICE_STATE=$(pgrep mysql | wc -l)
    SERVICE_STATE=$(ps -ef | grep -v grep | grep JDownloader | wc -l)
    if [ "$SERVICE_STATE" -eq 0 ]; then
    echo -e "$RED""WARNING! Service jdownloader is down.""$NC"
    else
  19. atiris revised this gist May 30, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -189,8 +189,8 @@ Description=JDownloader2 headless server daemon with autorestart.
    After=network.target
    [Service]
    Environment='DIR=/opt/JDownloader'
    Type=simple
    Environment=\"DIR=/opt/JDownloader\"
    WorkingDirectory=\${DIR}
    ExecStart=/usr/bin/java -Djava.awt.headless=true -jar \${DIR}/JDownloader.jar
    Restart=on-failure
    @@ -208,7 +208,7 @@ WantedBy=multi-user.target
    systemctl start jdownloader

    SERVICE_STATE=$(pgrep mysql | wc -l)
    if ["$SERVICE_STATE" -eq 0]; then
    if [ "$SERVICE_STATE" -eq 0 ]; then
    echo -e "$RED""WARNING! Service jdownloader is down.""$NC"
    else
    echo -e "Service jdownloader started > ""$GREEN""OK""$NC"
  20. atiris revised this gist May 30, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -142,8 +142,7 @@ if [[ $response =~ ^(yes|y) ]]; then

    sudo -u $RUN_AS_USER wget -O /opt/JDownloader/JDownloader.jar --progress=bar:force http://installer.jdownloader.org/JDownloader.jar

    echo -e "$BLUE"
    echo "Starting JDownloader installation."
    echo -e "$BLUE""Starting JDownloader installation."
    echo "Wait for the login / password request."
    echo "Register here: https://my.jdownloader.org/"
    echo -e "$NC"
  21. atiris revised this gist May 30, 2018. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,7 @@
    # and run gist from web is not recommended procedure in terms of security
    # https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a
    # - And then run it:
    # curl -Ls https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # or
    # wget -O - https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # SCRIPT=`curl -Ls https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw`; sudo bash -c "$SCRIPT"
    # Inspiration:
    # - https://gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f
    # - https://github.com/PlusMinus0/headless-jd2-docker
    @@ -47,7 +45,7 @@ else
    response=y
    fi

    if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    if [[ $response =~ ^(yes|y) ]]; then
    echo "-----BEGIN PGP PUBLIC KEY BLOCK-----
    Version: SKS 1.1.5
    Comment: Hostname: keyserver.ubuntu.com
    @@ -105,7 +103,7 @@ else
    response=y
    fi

    if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    if [[ $response =~ ^(yes|y) ]]; then
    echo -e "$BLUE"
    echo "I'll download JDownloader from official site jdownloader.org."
    echo "Then I will run the installation process several times, until JDownloader"
    @@ -183,7 +181,7 @@ else
    response=y
    fi

    if [[ $response =~ ^(yes|y| ) ]] || [[ -z $response ]]; then
    if [[ $response =~ ^(yes|y) ]]; then
    echo ""
    touch /opt/JDownloader/JDownloader.pid

  22. atiris revised this gist May 30, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,8 @@ JAVA_VERSION_LOCAL=`echo $(java -version 2>&1)| awk -F \" '{print $2}'`
    if [[ $JAVA_VERSION_LOCAL = *[!\ ]* ]]; then
    echo -e "Local java version is ""$RED""$JAVA_VERSION_LOCAL""$NC"
    response=n
    echo -e ""$RED""Install java anyway?""$NC"
    echo ""
    echo -e "$RED""Install java anyway?""$NC"
    read -p "[y/N] " response
    response=${response,,}
    else
    @@ -94,8 +95,9 @@ echo ""
    if [ -e /opt/JDownloader/JDownloader.jar ]; then
    FILE_DATE=$(date -r /opt/JDownloader/JDownloader.jar +%Y-%m-%d)
    echo -e "JDownloader already installed. File date is ""$RED""$FILE_DATE""$NC""."
    echo -e "$RED""Remove it and install actual JDownloader anyway?""$NC"
    echo ""
    response=n
    echo -e "$RED""Remove it and install actual JDownloader anyway?""$NC"
    read -p "[y/N] " response
    response=${response,,}
    else
  23. atiris revised this gist May 30, 2018. 1 changed file with 21 additions and 18 deletions.
    39 changes: 21 additions & 18 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -37,12 +37,13 @@ echo ""
    JAVA_VERSION_LOCAL=`echo $(java -version 2>&1)| awk -F \" '{print $2}'`
    if [[ $JAVA_VERSION_LOCAL = *[!\ ]* ]]; then
    echo -e "Local java version is ""$RED""$JAVA_VERSION_LOCAL""$NC"
    response="n"
    read -r -p $'\e[91mInstall java anyway?\e[0m [y/N] ' response
    response=n
    echo -e ""$RED""Install java anyway?""$NC"
    read -p "[y/N] " response
    response=${response,,}
    else
    echo -e "$YELLOW""Java is not installed.""$GREEN"" I will run the installation for you.""$NC"
    response="y"
    response=y
    fi
    if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    @@ -91,15 +92,15 @@ echo ""
    # JDownloader
    if [ -e /opt/JDownloader/JDownloader.jar ]; then
    echo -e "$YELLOW""JDownloader is not installed.""$GREEN"" Let me run it.""$NC"
    response="y"
    else
    FILE_DATE=$(date -r /opt/JDownloader/JDownloader.jar +%Y-%m-%d)
    echo -e "JDownloader already installed. File date is ""$RED""$FILE_DATE""$NC""."
    echo ""
    response="n"
    read -r -p $'\e[0mRemove it and install actual JDownloader anyway?\e[0m [y/N] ' response
    response=${response,,}
    echo -e "$RED""Remove it and install actual JDownloader anyway?""$NC"
    response=n
    read -p "[y/N] " response
    response=${response,,}
    else
    echo -e "$YELLOW""JDownloader is not installed.""$GREEN"" Let me run it.""$NC"
    response=y
    fi
    if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    @@ -113,7 +114,8 @@ if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    echo "You can continue in next step with installation of daemon,"
    echo "to start JDownloader automatically on reboot or after crash."
    echo -e "$NC"
    read -p "Press enter to OK"
    echo "Press enter to OK"
    read
    echo ""
    RUN_AS_USER=root
    @@ -151,8 +153,8 @@ if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    do
    doNextLoop=0
    sudo -u $RUN_AS_USER java -jar /opt/JDownloader/JDownloader.jar -norestart
    echo ""
    read -r -p $'\e[0mYou have already seen a request to enter your login information?\e[0m [y/N] ' response
    echo -e "$RED""You have already seen a request to enter your login information?""$NC"
    read -p "[y/N] " response
    response=${response,,}
    if [[ $response =~ ^(no|n| ) ]] || [[ -z $response ]]; then
    doNextLoop=1
    @@ -168,14 +170,15 @@ echo ""
    if [ -e /etc/systemd/system/jdownloader.service ]; then
    FILE_DATE=$(date -r /etc/systemd/system/jdownloader.service +%Y-%m-%d)
    echo "Service jdownloader already exists. File date is ""$RED""$FILE_DATE""$NC""."
    echo -e "Service jdownloader already exists. File date is ""$RED""$FILE_DATE""$NC""."
    echo ""
    response="n"
    read -r -p $'\e[0mReplace existing with default service implementation?\e[0m [y/N] ' response
    response=n
    echo -e "$RED""Replace existing with default service implementation?""$NC"
    read -p "[y/N] " response
    response=${response,,}
    else
    echo -e "$YELLOW""Service for jdownloader not exists yet.""$GREEN""No worries, I will create it.""$NC"
    response="y"
    response=y
    fi
    if [[ $response =~ ^(yes|y| ) ]] || [[ -z $response ]]; then
    @@ -209,7 +212,7 @@ WantedBy=multi-user.target
    if ["$SERVICE_STATE" -eq 0]; then
    echo -e "$RED""WARNING! Service jdownloader is down.""$NC"
    else
    echo "Service jdownloader started > ""$GREEN""OK""$NC"
    echo -e "Service jdownloader started > ""$GREEN""OK""$NC"
    fi
    echo ""
  24. atiris revised this gist May 30, 2018. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ echo ""

    JAVA_VERSION_LOCAL=`echo $(java -version 2>&1)| awk -F \" '{print $2}'`
    if [[ $JAVA_VERSION_LOCAL = *[!\ ]* ]]; then
    echo -e "Local java version is ""$BLUE""$JAVA_VERSION_LOCAL""$NC"
    echo -e "Local java version is ""$RED""$JAVA_VERSION_LOCAL""$NC"
    response="n"
    read -r -p $'\e[91mInstall java anyway?\e[0m [y/N] ' response
    response=${response,,}
    @@ -73,7 +73,8 @@ xTdyLkFCrbbIAZEHtmjXRgQu3VUcSkgHMdn46j/7N9qtZUcXQ0TOsZUJRANY/eHsBvUg1cBm
    echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list

    apt-get update

    apt-get install -f
    dpkg --configure -a
    apt-get install -y oracle-java8-installer

    apt-get install -y oracle-java8-set-default
    @@ -90,15 +91,15 @@ echo ""
    # JDownloader

    if [ -e /opt/JDownloader/JDownloader.jar ]; then
    echo -e "$YELLOW""JDownloader is not installed.""$GREEN"" Let me run it.""$NC"
    response="y"
    else
    FILE_DATE=$(date -r /opt/JDownloader/JDownloader.jar +%Y-%m-%d)
    echo -e "JDownloader already installed. File date is ""$BLUE""$FILE_DATE""$NC""."
    echo -e "JDownloader already installed. File date is ""$RED""$FILE_DATE""$NC""."
    echo ""
    response="n"
    read -r -p $'\e[0mRemove it and install actual JDownloader anyway?\e[0m [y/N] ' response
    response=${response,,}
    else
    echo -e "$YELLOW""JDownloader is not installed.""$GREEN"" Let me run it.""$NC"
    response="y"
    fi

    if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    @@ -167,7 +168,7 @@ echo ""

    if [ -e /etc/systemd/system/jdownloader.service ]; then
    FILE_DATE=$(date -r /etc/systemd/system/jdownloader.service +%Y-%m-%d)
    echo "Service jdownloader already exists. File changed at $FILE_DATE."
    echo "Service jdownloader already exists. File date is ""$RED""$FILE_DATE""$NC""."
    echo ""
    response="n"
    read -r -p $'\e[0mReplace existing with default service implementation?\e[0m [y/N] ' response
  25. atiris revised this gist May 30, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -67,6 +67,8 @@ xTdyLkFCrbbIAZEHtmjXRgQu3VUcSkgHMdn46j/7N9qtZUcXQ0TOsZUJRANY/eHsBvUg1cBm

    rm -f temporarykey.txt

    echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
    echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
    echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
    echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list

  26. atiris revised this gist May 30, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,9 @@
    # and run gist from web is not recommended procedure in terms of security
    # https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a
    # - And then run it:
    # curl https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # or
    # wget https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # curl -Ls https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # or
    # wget -O - https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # Inspiration:
    # - https://gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f
    # - https://github.com/PlusMinus0/headless-jd2-docker
  27. atiris revised this gist May 30, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,9 @@
    # and run gist from web is not recommended procedure in terms of security
    # https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a
    # - And then run it:
    # curl https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw/ | sudo bash
    # curl https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # or
    # wget https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw/ | sudo bash
    # wget https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw | sudo bash
    # Inspiration:
    # - https://gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f
    # - https://github.com/PlusMinus0/headless-jd2-docker
  28. atiris revised this gist May 30, 2018. 1 changed file with 220 additions and 0 deletions.
    220 changes: 220 additions & 0 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -4,3 +4,223 @@
    # Author: Jozef Pažin
    # Description: Wizard to install the current version of jdownloader on raspberry pi running osmc kodi.
    # License: MIT
    # How to run:
    # - Check it first if this code is correct because this script need to be run under root
    # and run gist from web is not recommended procedure in terms of security
    # https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a
    # - And then run it:
    # curl https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw/ | sudo bash
    # or
    # wget https://gist.github.com/atiris/34dc670264274b3a472f2a718e4de83a/raw/ | sudo bash
    # Inspiration:
    # - https://gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f
    # - https://github.com/PlusMinus0/headless-jd2-docker
    # - https://gist.github.com/leosuncin/50367b3c905fe8699b13bd85ad26071b

    if [[ "$EUID" -ne 0 ]]; then
    echo ""
    echo "Please login as root: sudo su"
    echo ""
    return
    fi

    # Colors
    NC='\033[0m'
    RED='\033[0;91m'
    GREEN='\033[0;92m'
    BLUE='\033[0;94m'
    YELLOW='\033[0;93m'

    echo ""
    # Java

    JAVA_VERSION_LOCAL=`echo $(java -version 2>&1)| awk -F \" '{print $2}'`
    if [[ $JAVA_VERSION_LOCAL = *[!\ ]* ]]; then
    echo -e "Local java version is ""$BLUE""$JAVA_VERSION_LOCAL""$NC"
    response="n"
    read -r -p $'\e[91mInstall java anyway?\e[0m [y/N] ' response
    response=${response,,}
    else
    echo -e "$YELLOW""Java is not installed.""$GREEN"" I will run the installation for you.""$NC"
    response="y"
    fi

    if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    echo "-----BEGIN PGP PUBLIC KEY BLOCK-----
    Version: SKS 1.1.5
    Comment: Hostname: keyserver.ubuntu.com
    mI0ES9/P3AEEAPbI+9BwCbJucuC78iUeOPKl/HjAXGV49FGat0PcwfDd69MVp6zUtIMbLgkU
    OxIlhiEkDmlYkwWVS8qy276hNg9YKZP37ut5+GPObuS6ZWLpwwNus5PhLvqeGawVJ/obu7d7
    gM8mBWTgvk0ErnZDaqaU2OZtHataxbdeW8qH/9FJABEBAAG0DUxhdW5jaHBhZCBWTEOImwQQ
    AQIABgUCVsN4HQAKCRAEC6TrO3+B2tJkA/jM3b7OysTwptY7P75sOnIu+nXLPlzvja7qH7Wn
    A23itdSker6JmyJrlQeQZu7b9x2nFeskNYlnhCp9mUGu/kbAKOx246pBtlaipkZdGmL4qXBi
    +bi6+5Rw2AGgKndhXdEjMxx6aDPq3dftFXS68HyBM3HFSJlf7SmMeJCkhNRwiLYEEwECACAF
    Akvfz9wCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRDCUYJI7qFIhucGBADQnY4V1xKT
    1Gz+3ERly+nBb61BSqRx6KUgvTSEPasSVZVCtjY5MwghYU8T0h1PCx2qSir4nt3vpZL1luW2
    xTdyLkFCrbbIAZEHtmjXRgQu3VUcSkgHMdn46j/7N9qtZUcXQ0TOsZUJRANY/eHsBvUg1cBm
    3RnCeN4C8QZrir1CeA==
    =CziK
    -----END PGP PUBLIC KEY BLOCK-----" > temporarykey.txt

    apt-key add temporarykey.txt

    rm -f temporarykey.txt

    echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
    echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list

    apt-get update

    apt-get install -y oracle-java8-installer

    apt-get install -y oracle-java8-set-default

    echo ""
    echo -e "$GREEN""Java installation is complete.""$NC"
    echo "Actual java vesion on your system is:"
    java -version
    else
    echo "Java installation skipped."
    fi

    echo ""
    # JDownloader

    if [ -e /opt/JDownloader/JDownloader.jar ]; then
    FILE_DATE=$(date -r /opt/JDownloader/JDownloader.jar +%Y-%m-%d)
    echo -e "JDownloader already installed. File date is ""$BLUE""$FILE_DATE""$NC""."
    echo ""
    response="n"
    read -r -p $'\e[0mRemove it and install actual JDownloader anyway?\e[0m [y/N] ' response
    response=${response,,}
    else
    echo -e "$YELLOW""JDownloader is not installed.""$GREEN"" Let me run it.""$NC"
    response="y"
    fi

    if [[ $response =~ ^(yes|y) ]] || [[ -z $response ]]; then
    echo -e "$BLUE"
    echo "I'll download JDownloader from official site jdownloader.org."
    echo "Then I will run the installation process several times, until JDownloader"
    echo "ask you for login and password. Please press \"y\" at that time, and set"
    echo "your credentials from my.jdownloader.org (you must first be registered)."
    echo "Then wait some time (few seconds) until JDownloader save this settings"
    echo "and interrupt JDownloader installation by pressing \"CTRL+C\"."
    echo "You can continue in next step with installation of daemon,"
    echo "to start JDownloader automatically on reboot or after crash."
    echo -e "$NC"
    read -p "Press enter to OK"
    echo ""

    RUN_AS_USER=root
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u osmc 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Install JDownloader with 'osmc' user rights."
    RUN_AS_USER=osmc
    fi
    if [[ "$RUN_AS_USER" == 'root' ]] && [[ `id -u pi 2>/dev/null || echo -1` -ge 0 ]]; then
    echo "Install JDownloader with 'pi' user rights."
    RUN_AS_USER=pi
    fi
    if [ "$RUN_AS_USER" == 'root' ]; then
    echo "Installing as 'root'."
    fi

    if [ ! -d /opt/JDownloader ]; then
    mkdir -p /opt/JDownloader
    echo "Folder /opt/JDownloader created."
    else
    rm -rf /opt/JDownloader/*
    echo "Folder for JDownloader cleaned."
    fi
    chown -fR $RUN_AS_USER:users /opt/JDownloader

    sudo -u $RUN_AS_USER wget -O /opt/JDownloader/JDownloader.jar --progress=bar:force http://installer.jdownloader.org/JDownloader.jar

    echo -e "$BLUE"
    echo "Starting JDownloader installation."
    echo "Wait for the login / password request."
    echo "Register here: https://my.jdownloader.org/"
    echo -e "$NC"

    doNextLoop=1
    while [ $doNextLoop -eq 1 ]
    do
    doNextLoop=0
    sudo -u $RUN_AS_USER java -jar /opt/JDownloader/JDownloader.jar -norestart
    echo ""
    read -r -p $'\e[0mYou have already seen a request to enter your login information?\e[0m [y/N] ' response
    response=${response,,}
    if [[ $response =~ ^(no|n| ) ]] || [[ -z $response ]]; then
    doNextLoop=1
    fi
    done
    echo -e "$GREEN""JDownloader instalation is complete.""$NC"
    else
    echo "JDownloader installation skipped."
    fi

    echo ""
    # Service systemd jdownloader

    if [ -e /etc/systemd/system/jdownloader.service ]; then
    FILE_DATE=$(date -r /etc/systemd/system/jdownloader.service +%Y-%m-%d)
    echo "Service jdownloader already exists. File changed at $FILE_DATE."
    echo ""
    response="n"
    read -r -p $'\e[0mReplace existing with default service implementation?\e[0m [y/N] ' response
    response=${response,,}
    else
    echo -e "$YELLOW""Service for jdownloader not exists yet.""$GREEN""No worries, I will create it.""$NC"
    response="y"
    fi

    if [[ $response =~ ^(yes|y| ) ]] || [[ -z $response ]]; then
    echo ""
    touch /opt/JDownloader/JDownloader.pid

    echo "[Unit]
    Description=JDownloader2 headless server daemon with autorestart.
    After=network.target
    [Service]
    Type=simple
    Environment=\"DIR=/opt/JDownloader\"
    WorkingDirectory=\${DIR}
    ExecStart=/usr/bin/java -Djava.awt.headless=true -jar \${DIR}/JDownloader.jar
    Restart=on-failure
    RestartSec=10s
    [Install]
    WantedBy=multi-user.target
    " > /etc/systemd/system/jdownloader.service

    if [ -e /etc/systemd/system/jdownloader.service ]; then
    systemctl daemon-reload
    echo -e "Service /etc/systemd/user/jdownloader.service > ""$GREEN""created OK""$NC"
    systemctl enable jdownloader
    echo -e "Service jdownloader enabled > ""$GREEN""OK""$NC"
    systemctl start jdownloader

    SERVICE_STATE=$(pgrep mysql | wc -l)
    if ["$SERVICE_STATE" -eq 0]; then
    echo -e "$RED""WARNING! Service jdownloader is down.""$NC"
    else
    echo "Service jdownloader started > ""$GREEN""OK""$NC"
    fi

    echo ""
    echo -e "$GREEN""Service installation is complete.""$NC"
    echo "You can check service status with: systemctl status jdownloader"
    else
    echo -e "$RED""ERROR! I can not create a service.""$NC"
    fi
    else
    echo "Service installation skipped."
    fi

    echo ""
    # Final message

    echo -e "$GREEN""That's all, I hope everything works for you.""$NC"
    echo -e "$GREEN""Now you can check JDownloader on https://my.jdownloader.org/""$NC"
  29. atiris created this gist May 30, 2018.
    6 changes: 6 additions & 0 deletions osmc-java-jdownloader-installer.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #!/bin/bash

    # Script: osmc-java-jdownloader-installer.sh
    # Author: Jozef Pažin
    # Description: Wizard to install the current version of jdownloader on raspberry pi running osmc kodi.
    # License: MIT