|
|
|
@ -39,13 +39,13 @@ EOF
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init() { |
|
|
|
|
sudo mkdir -p $START |
|
|
|
|
sudo mkdir -p $OPT |
|
|
|
|
sudo touch $LIST |
|
|
|
|
if [ ! -s $LIST ]; then |
|
|
|
|
sudo mkdir -p "$START" |
|
|
|
|
sudo mkdir -p "$OPT" |
|
|
|
|
sudo touch "$LIST" |
|
|
|
|
if [ ! -s "$LIST" ]; then |
|
|
|
|
# Append to empty file |
|
|
|
|
sudo sh -c 'echo "start:" >> '$LIST |
|
|
|
|
sudo sh -c 'echo "opt:" >> '$LIST |
|
|
|
|
sudo sh -c 'echo "start:" >> '"$LIST" |
|
|
|
|
sudo sh -c 'echo "opt:" >> '"$LIST" |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -54,7 +54,7 @@ list() {
|
|
|
|
|
echo "Listing all installed plugins.." |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
PLUGIN="$(find $DIR -mindepth 2 -maxdepth 2 \ |
|
|
|
|
PLUGIN="$(find "$DIR" -mindepth 2 -maxdepth 2 \ |
|
|
|
|
| sort | awk -F '/' '{ print $(NF-1)"/"$NF }')" |
|
|
|
|
NUM=0 |
|
|
|
|
for p in $PLUGIN; do |
|
|
|
@ -70,23 +70,23 @@ list() {
|
|
|
|
|
|
|
|
|
|
install() { |
|
|
|
|
# Check if correct git URL |
|
|
|
|
if [ -z "$(echo $1 | sed -nr \ |
|
|
|
|
if [ -z "$(echo "$1" | sed -nr \ |
|
|
|
|
's/^https:\/\/github\.com\/(.*\/.*).git$/\1/p')" ]; then |
|
|
|
|
echo "script: url invalid: $1" |
|
|
|
|
else |
|
|
|
|
# cd to correct directory if called from the CLI |
|
|
|
|
if [ -z "$2" ]; then |
|
|
|
|
# Default is directory 'start' |
|
|
|
|
cd "$START" |
|
|
|
|
cd "$START" || exit |
|
|
|
|
elif [ "$2" = "start" ]; then |
|
|
|
|
cd "$START" |
|
|
|
|
cd "$START" || exit |
|
|
|
|
elif [ "$2" = "opt" ]; then |
|
|
|
|
cd "$OPT" |
|
|
|
|
cd "$OPT" || exit |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
REPO="$(basename $1 .git)" |
|
|
|
|
REPO="$(basename "$1" .git)" |
|
|
|
|
if [ -d "$REPO" ]; then |
|
|
|
|
cd "$REPO" |
|
|
|
|
cd "$REPO" || exit |
|
|
|
|
sudo git pull --force 1> /dev/null |
|
|
|
|
cd ".." |
|
|
|
|
echo "Updated: $REPO" |
|
|
|
@ -96,13 +96,13 @@ install() {
|
|
|
|
|
# Add git URL to config file |
|
|
|
|
if [ -z "$2" ]; then |
|
|
|
|
# Append before 'opt:' |
|
|
|
|
sudo sed -i '/opt:/ i '$1 $LIST |
|
|
|
|
sudo sed -i '/opt:/ i '"$1" "$LIST" |
|
|
|
|
elif [ "$2" = "start" ]; then |
|
|
|
|
# Append before 'opt:' |
|
|
|
|
sudo sed -i '/opt:/ i '$1 $LIST |
|
|
|
|
sudo sed -i '/opt:/ i '"$1" "$LIST" |
|
|
|
|
elif [ "$2" = "opt" ]; then |
|
|
|
|
# Append at the end of the file |
|
|
|
|
sudo sed -i '$ a '$1 $LIST |
|
|
|
|
sudo sed -i '$ a '"$1" "$LIST" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
echo "Installed: $REPO" |
|
|
|
@ -115,30 +115,30 @@ update() {
|
|
|
|
|
|
|
|
|
|
init |
|
|
|
|
|
|
|
|
|
cd $START |
|
|
|
|
while read l; do |
|
|
|
|
cd "$START" || exit |
|
|
|
|
while read -r l; do |
|
|
|
|
if [ "$l" = "start:" ]; then |
|
|
|
|
cd "$START" |
|
|
|
|
cd "$START" || exit |
|
|
|
|
elif [ "$l" = "opt:" ]; then |
|
|
|
|
cd "$OPT" |
|
|
|
|
cd "$OPT" || exit |
|
|
|
|
else |
|
|
|
|
install $l "script" |
|
|
|
|
install "$l" "script" |
|
|
|
|
fi |
|
|
|
|
done < $LIST |
|
|
|
|
done < "$LIST" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
remove() { |
|
|
|
|
list |
|
|
|
|
echo -n "Enter the number to remove: " |
|
|
|
|
read OPTION |
|
|
|
|
read -r OPTION |
|
|
|
|
|
|
|
|
|
if [ -z "$(echo $OPTION | sed -nr 's/^([0-9]+)$/\1/p')" ]; then |
|
|
|
|
if [ -z "$(echo "$OPTION" | sed -nr 's/^([0-9]+)$/\1/p')" ]; then |
|
|
|
|
echo "Please select a number" |
|
|
|
|
else |
|
|
|
|
TO_REMOVE="$(list $OPTION)" |
|
|
|
|
TO_REMOVE="$(list "$OPTION")" |
|
|
|
|
if [ -n "$TO_REMOVE" ]; then |
|
|
|
|
sudo rm -rf $DIR/$TO_REMOVE |
|
|
|
|
sudo sed -i '/'"$(basename $TO_REMOVE)"'\.git/d' $LIST |
|
|
|
|
sudo rm -rf "$DIR/$TO_REMOVE" |
|
|
|
|
sudo sed -i '/'"$(basename "$TO_REMOVE")"'\.git/d' "$LIST" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|