Skip to content

Instantly share code, notes, and snippets.

@giabao
Last active May 23, 2016 15:22
Show Gist options
  • Select an option

  • Save giabao/8414868 to your computer and use it in GitHub Desktop.

Select an option

Save giabao/8414868 to your computer and use it in GitHub Desktop.

Revisions

  1. giabao revised this gist May 23, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions dl
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,6 @@ sudo tar -xzf jdk-8u91-linux-x64.tar.gz
    sudo ln -sfT jdk1.8.0_91 default
    sudo rm -f jdk-8u91-linux-x64.tar.gz
    update-alternatives --display java
    sudo update-alternatives --install /usr/bin/java java /opt/jdk/default/bin/java 1
    sudo update-alternatives --install /usr/bin/java java /opt/java/default/bin/java 1
    java -version
    sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/default/bin/javac 1
    sudo update-alternatives --install /usr/bin/javac javac /opt/java/default/bin/javac 1
  2. giabao revised this gist May 23, 2016. 1 changed file with 13 additions and 27 deletions.
    40 changes: 13 additions & 27 deletions dl
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,13 @@
    #!/bin/bash
    #Use aria2c to download file
    #1. add params (to speedup downloading): -s16 -x16 -k1M
    #2. add --check-certificate=false --file-allocation=falloc
    # see http://aria2.sourceforge.net/manual/en/html/aria2c.html#cmdoption--file-allocation
    #3. simulate -o option of curl:
    # dl -o /dir/file url
    # will download file to /dir/file insteads of ./dir/file

    args=" $@"

    # parse -o
    pat=".*\(\s-o\s*[^ ]*\).*"
    val=`expr match "$args" "$pat"`

    #parse --out=
    if [ ! "$val" ]; then
    pat=".*\(\s--out=\s*[^ ]*\).*"
    val=`expr match "$args" "$pat"`
    fi

    if [ "$val" ]; then
    args="-d /$args"
    fi

    args="-s16 -x16 -k1M --check-certificate=false --file-allocation=falloc $args"
    exec /usr/bin/aria2c $args
    alias dl='aria2c -x16 -s16 -k1M'

    cd ~/Downloads/
    dl --header="Cookie: oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
    sudo mkdir -p /opt/java && cd /opt/java
    sudo mv ~/Downloads/jdk-8u91-linux-x64.tar.gz .
    sudo tar -xzf jdk-8u91-linux-x64.tar.gz
    sudo ln -sfT jdk1.8.0_91 default
    sudo rm -f jdk-8u91-linux-x64.tar.gz
    update-alternatives --display java
    sudo update-alternatives --install /usr/bin/java java /opt/jdk/default/bin/java 1
    java -version
    sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/default/bin/javac 1
  3. giabao revised this gist Jan 15, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions dl
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    #!/bin/bash
    #Use aria2c to download file
    #1. add params (to speedup downloading): -s16 -x16 -k1M
    #2. add --check-certificate=false
    #2. add --check-certificate=false --file-allocation=falloc
    # see http://aria2.sourceforge.net/manual/en/html/aria2c.html#cmdoption--file-allocation
    #3. simulate -o option of curl:
    # dl -o /dir/file url
    # will download file to /dir/file insteads of ./dir/file
    @@ -22,5 +23,5 @@ if [ "$val" ]; then
    args="-d /$args"
    fi

    args="-s16 -x16 -k1M --check-certificate=false $args"
    args="-s16 -x16 -k1M --check-certificate=false --file-allocation=falloc $args"
    exec /usr/bin/aria2c $args
  4. giabao created this gist Jan 14, 2014.
    26 changes: 26 additions & 0 deletions dl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/bin/bash
    #Use aria2c to download file
    #1. add params (to speedup downloading): -s16 -x16 -k1M
    #2. add --check-certificate=false
    #3. simulate -o option of curl:
    # dl -o /dir/file url
    # will download file to /dir/file insteads of ./dir/file

    args=" $@"

    # parse -o
    pat=".*\(\s-o\s*[^ ]*\).*"
    val=`expr match "$args" "$pat"`

    #parse --out=
    if [ ! "$val" ]; then
    pat=".*\(\s--out=\s*[^ ]*\).*"
    val=`expr match "$args" "$pat"`
    fi

    if [ "$val" ]; then
    args="-d /$args"
    fi

    args="-s16 -x16 -k1M --check-certificate=false $args"
    exec /usr/bin/aria2c $args