|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -e |
| 3 | +if [ "$EUID" == "0" ] |
| 4 | +then |
| 5 | + echo "Running as root" |
| 6 | +elif [[ "$(which sudo)" != "" ]] |
| 7 | +then |
| 8 | + echo "Running as sudo" |
| 9 | + if [[ "$0" == "bash" ]]; then |
| 10 | + exec curl -sSL https://raw.githubusercontent.com/gitdev-bash/piduck/master/install.sh | sudo bash "$@" |
| 11 | + else |
| 12 | + exec sudo bash "$0" "$@" |
| 13 | + fi |
| 14 | + exit $? |
| 15 | +fi |
| 16 | +#if [[ -d "/etc/piduck" ]] |
| 17 | +#then |
| 18 | +# echo "Seems like piduck is already installed!" |
| 19 | +# exit 4 |
| 20 | +#else |
| 21 | +if [[ "$(which git)" != "" ]] |
| 22 | +then |
| 23 | + echo "Using git!" |
| 24 | + git clone https://github.com/gitdev-bash/piduck.git /tmp/piduck |
| 25 | +elif [[ "$(which wget)" != "" && "$(which unzip)" != "" ]] |
| 26 | +then |
| 27 | + echo "Using wget and unzip" |
| 28 | + wget -q -O /tmp/piduck.zip https://github.com/gitdev-bash/piduck/zipball/master/ |
| 29 | + unzip /tmp/piduck.zip |
| 30 | + rm /tmp/piduck.zip |
| 31 | +elif [[ "$(which curl)" != "" && "$(which unzip)" != "" ]] |
| 32 | +then |
| 33 | + echo "Using curl and unzip" |
| 34 | + curl -sSL -o /tmp/piduck.zip https://github.com/gitdev-bash/piduck/zipball/master/ |
| 35 | + unzip /tmp/piduck.zip |
| 36 | + rm /tmp/piduck.zip |
| 37 | +elif [[ "$(which wget)" != "" && "$(which gunzip)" != "" ]] |
| 38 | +then |
| 39 | + echo "Using wget and gunzip" |
| 40 | + wget -q -O /tmp/piduck.zip https://github.com/gitdev-bash/piduck/tarball/master/ |
| 41 | + tar -xzvf /tmp/piduck.tar.gz |
| 42 | + rm /tmp/piduck.tar.gz |
| 43 | +elif [[ "$(which curl)" != "" && "$(which gunzip)" != "" ]] |
| 44 | +then |
| 45 | + echo "Using curl and gunzip" |
| 46 | + curl -sSL -o /tmp/piduck.zip https://github.com/gitdev-bash/piduck/tarball/master/ |
| 47 | + tar -xzvf /tmp/piduck.tar.gz |
| 48 | + rm /tmp/piduck.tar.gz |
| 49 | +else |
| 50 | + echo "Ops missing dependencies" |
| 51 | + exit 2 |
| 52 | +fi |
| 53 | +mkdir /etc/piduck |
| 54 | +mv /tmp/piduck/piduck.py /etc/piduck/piduck.py |
| 55 | +mv /tmp/piduck/pd_key_maps /etc/piduck/pd_key_maps |
| 56 | +mv /tmp/piduck/requirements.txt /etc/piduck/requirements.txt |
| 57 | +chmod 555 /etc/piduck/piduck.py /etc/piduck/pd_key_maps/* |
| 58 | +chmod 444 /etc/piduck/pd_key_maps/* /etc/piduck/requirements.txt |
| 59 | +rm -rf /tmp/piduck |
| 60 | +ln -s /etc/piduck/piduck.py /usr/bin/piduck |
| 61 | +#fi |
| 62 | +echo "DONE!" |
| 63 | +exit 0 |
0 commit comments