|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +_c_magneta="\e[95m" |
| 4 | +_c_green="\e[32m" |
| 5 | +_c_red="\e[31m" |
| 6 | +_c_blue="\e[34m" |
| 7 | +RST="\e[0m" |
| 8 | + |
| 9 | +die() { echo -e "${_c_red}[E] ${*}${RST}";exit 1;:;} |
| 10 | +warn() { echo -e "${_c_red}[W] ${*}${RST}";:;} |
| 11 | +shout() { echo -e "${_c_blue}[-] ${*}${RST}";:;} |
| 12 | +lshout() { echo -e "${_c_blue}-> ${*}${RST}";:;} |
| 13 | +imsg() { if [ -n "$UDROID_VERBOSE" ]; then echo -e ": ${*} \e[0m" >&2;fi;:;} |
| 14 | +msg() { echo -e "${*} \e[0m" >&2;:;} |
| 15 | + |
| 16 | +if ! command -v python3 >/dev/null 2>&1; then |
| 17 | + die "Python3 is not installed" |
| 18 | +fi |
| 19 | + |
| 20 | +if (( UID != 0 )); then |
| 21 | + die "You need to be root to run this script" |
| 22 | +fi |
| 23 | + |
| 24 | +shout "Installing udroidmgr" |
| 25 | +mkdir -pv /usr/share/udroid || { |
| 26 | + die "Failed to create /usr/share/udroid" |
| 27 | +} |
| 28 | + |
| 29 | +if [ -d utils ]; then |
| 30 | + cp -rv utils /usr/share/udroid/ || { |
| 31 | + die "Failed to copy utils" |
| 32 | + } |
| 33 | +fi |
| 34 | + |
| 35 | +if [ -f main.py ]; then |
| 36 | + cp -v main.py /usr/share/udroid/ || { |
| 37 | + die "Failed to copy main.py" |
| 38 | + } |
| 39 | +fi |
| 40 | + |
| 41 | +if [ -f main.sh ]; then |
| 42 | + cp -v main.sh /usr/share/udroid/ || { |
| 43 | + die "Failed to copy main.sh" |
| 44 | + } |
| 45 | +fi |
| 46 | + |
| 47 | + |
| 48 | +if [[ -f /usr/bin/startvnc ]]; then |
| 49 | + rm -rvf /usr/bin/startvnc |
| 50 | +fi |
| 51 | + |
| 52 | +if [[ -f /usr/bin/stopvnc ]]; then |
| 53 | + rm -rvf /usr/bin/stopvnc |
| 54 | +fi |
| 55 | + |
| 56 | +ln -sv /usr/share/udroid/main.sh /usr/bin/startvnc || { |
| 57 | + die "Failed to create symlink" |
| 58 | +} |
| 59 | +ln -sv /usr/share/udroid/main.sh /usr/bin/stopvnc || { |
| 60 | + die "Failed to create symlink" |
| 61 | +} |
0 commit comments