Skip to content

Commit 92ee2d1

Browse files
ADD:reset,remove,download cache
1 parent a3a0389 commit 92ee2d1

File tree

2 files changed

+81
-7
lines changed

2 files changed

+81
-7
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
#
4+
# A quick script to force remove a proot installation
5+
#
6+
7+
FS_PATH=$1
8+
[[ -z $FS_PATH ]] && echo "no path provided" && exit 1
9+
[[ ! -d $FS_PATH ]] && echo "path not found" && exit 1
10+
11+
# fix-up permissions
12+
chmod u+rwx -R $FS_PATH > /dev/null 2>&1 || true
13+
14+
# remove files
15+
if ! rm -rf $FS_PATH > /dev/null 2>&1; then
16+
echo "failed to remove files"
17+
exit 1
18+
fi
19+

udroid/src/udroid.sh

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,56 @@ list() {
635635
}
636636

637637
remove() {
638-
:
638+
local _name
639+
local arg
640+
local path=${DEFAULT_FS_INSTALL_DIR}
641+
642+
while [ $# -gt 0 ]; do
643+
case $1 in
644+
--name) _name=$2; LOG "remove(): --name supplied to $name"; shift 2;;
645+
--path) path=$2; LOG "remove(): looking in $path"; shift 2;;
646+
--reset) reset=true; shift 1;;
647+
*)
648+
[[ -n $_name ]] && {
649+
ELOG "remove() error: name already set to $_name"
650+
echo "--name supplied $_name"
651+
}
652+
653+
if [[ -z $arg ]]; then
654+
arg=$1
655+
else
656+
ELOG "unkown option $1"
657+
fi
658+
shift
659+
break
660+
;;
661+
esac
662+
done
663+
664+
if [[ -z $_name ]]; then
665+
parser $arg "offline"
666+
distro=$name
667+
else
668+
distro=$_name
669+
fi
670+
root_fs_path=$path/$distro
671+
672+
[[ -z $distro ]] && echo "ERROR: distro not specified" && exit 1
673+
[[ ! -d $root_fs_path ]] && echo "ERROR: distro ($distro) not found or installed" && exit 1
674+
675+
g_spin "dot" \
676+
"setting up $distro to be removed" \
677+
bash proot-utils/proot-uninstall-suite.sh "$root_fs_path"
678+
679+
if [[ $reset == true ]]; then
680+
install $arg
681+
fi
682+
683+
}
684+
685+
_reset() {
686+
local arg=$1
687+
remove --reset $arg
639688
}
640689

641690
####################
@@ -648,11 +697,16 @@ download() {
648697

649698
LOG "download() args => name=$name link=$link path=$path"
650699

651-
wget -q --show-progress --progress=bar:force -O ${path}/$name "$link" 2>&1 || {
652-
ELOG "failed to download $name"
653-
echo "failed to download $name"
654-
exit 1
655-
}
700+
if [[ -f $path/$name ]]; then
701+
LOG "download(): $name already exists in $path"
702+
GWARN "$name already exists, continuing with existing file"
703+
else
704+
wget -q --show-progress --progress=bar:force -O ${path}/$name "$link" 2>&1 || {
705+
ELOG "failed to download $name"
706+
echo "failed to download $name"
707+
exit 1
708+
}
709+
fi
656710
}
657711

658712
msg_download() {
@@ -686,7 +740,8 @@ while [ $# -gt 0 ]; do
686740
case $1 in
687741
--install|-i) shift 1; install $@ ; break ;;
688742
--login|-l) shift 1; login $@; break ;;
689-
--remove | --uninstall ) ;;
743+
--remove | --uninstall ) remove $@; break;;
744+
--reset | --reinstall ) _reset $@; break;;
690745
--list) shift 1; list $@; break ;;
691746
*) echo "unkown option [$1]"; break ;;
692747
esac

0 commit comments

Comments
 (0)