Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix script upgrade #73

Merged
merged 8 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions advanced/Scripts/speedtestmod/mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ help() {
setTags() {
local path=${1-}
local name=${2-}
local branch="${3-master}"
if [ ! -z "$path" ]; then
cd "$path"
git fetch origin -q
git fetch origin $branch:refs/remotes/origin/$branch -q
git fetch --tags -f -q
latestTag=$(git describe --tags $(git rev-list --tags --max-count=1))
fi
Expand All @@ -52,37 +53,42 @@ download() {
local name=$2
local url=$3
local src=${4-}
local branch=${5-master}
local branch="${5-master}"
local dest=$path/$name
if [ ! -d $dest ]; then # replicate
cd "$path"
rm -rf "$name"
git clone --depth=1 -b "$branch" "$url" "$name"
setTags "$name" "$src"
git clone --depth=1 -b "$branch" "$url" "$name" -q
setTags "$name" "$src" $branch
if [ ! -z "$src" ]; then
if [[ "$localTag" == *.* ]] && [[ "$localTag" < "$latestTag" ]]; then
latestTag=$localTag
git fetch --unshallow
fi
fi
else # replace
setTags $dest
setTags $dest "" $branch
if [ ! -z "$src" ]; then
if [ "$url" != "old" ]; then
git config --global --add safe.directory "$dest"
git remote -v | grep -q "old" || git remote rename origin old
git remote -v | grep -q "origin" && git remote remove origin
git remote add origin $url
else
elif [ -d .git/refs/remotes/old ]; then
git remote remove origin
git remote rename old origin
fi
git fetch origin -q
fi
git reset --hard origin/$branch
git checkout -B $branch
git branch -u origin/$branch
git clean -ffdx
fi

git -c advice.detachedHead=false checkout $latestTag
if [ "$(git rev-parse HEAD)" != "$(git rev-parse $latestTag)" ]; then
git -c advice.detachedHead=false checkout $latestTag
fi
cd ..
}

Expand Down Expand Up @@ -147,7 +153,7 @@ install() {
fi

local PHP_VERSION=$(php -v | head -n 1 | awk '{print $2}' | cut -d "." -f 1,2)
local packages="bc sqlite3 php${PHP_VERSION}-sqlite3 jq"
local packages="bc sqlite3 php${PHP_VERSION}-sqlite3 jq tmux"

local missing_packages=""
for package in $packages; do
Expand All @@ -168,7 +174,7 @@ install() {
fi

download /opt mod_pihole https://github.com/arevindh/pi-hole
download /var/www/html admin https://github.com/arevindh/AdminLTE web
download $admin_dir admin https://github.com/arevindh/AdminLTE web
if [ -f $curr_wp ]; then
if ! cat $curr_wp | grep -q SpeedTest; then
cp -a $curr_wp $org_wp
Expand Down Expand Up @@ -199,20 +205,22 @@ uninstall() {
fi

pihole -a -su
download /var/www/html admin https://github.com/pi-hole/AdminLTE web
download $admin_dir admin https://github.com/pi-hole/AdminLTE web
if [ ! -f $last_wp ]; then
cp -a $curr_wp $last_wp
fi
cp -a $org_wp $curr_wp
chmod +x $curr_wp
rm -rf /opt/mod_pihole
pihole updatechecker
fi

manageHistory ${1-}
}

purge() {
rm -rf "$admin_dir"*_admin
rm -rf /opt/mod_pihole
rm -rf /opt/pihole/speedtestmod
if [ -f /etc/systemd/system/pihole-speedtest.timer ]; then
rm -f /etc/systemd/system/pihole-speedtest.service
rm -f /etc/systemd/system/pihole-speedtest.timer
Expand All @@ -225,6 +233,8 @@ purge() {
if isEmpty $curr_db; then
rm -f $curr_db
fi

pi-hole updatechecker
}

update() {
Expand Down
15 changes: 0 additions & 15 deletions advanced/Scripts/webpage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -682,37 +682,22 @@ SpeedtestServer() {
}

RunSpeedtestNow() {
if ! command -v tmux &> /dev/null; then
apt-get install tmux -y
fi
tmux new-session -d -s pimod "cat $speedtestfile | sudo bash"
}

ReinstallSpeedTest() {
if ! command -v tmux &> /dev/null; then
apt-get install tmux -y
fi
tmux new-session -d -s pimod "cat $speedtestmod | sudo bash"
}

UpdateSpeedTest() {
if ! command -v tmux &> /dev/null; then
apt-get install tmux -y
fi
tmux new-session -d -s pimod "cat $speedtestmod | sudo bash -s -- up ${args[2]} ${args[3]}"
}

UninstallSpeedTest() {
if ! command -v tmux &> /dev/null; then
apt-get install tmux -y
fi
tmux new-session -d -s pimod "cat $speedtestmod | sudo bash -s -- un ${args[2]}"
}

ClearSpeedtestData() {
if ! command -v tmux &> /dev/null; then
apt-get install tmux -y
fi
tmux new-session -d -s pimod "cat $speedtestmod | sudo bash -s -- db"
}

Expand Down
Loading