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

UPDATE_ scripts quality of life improvements #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion usr/bin/UPDATE_FIRMWARE
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ check_for_internet() {
echo "You must have an internet connection to check for updates."
exit 0
fi

if ! ping -q -c 1 -W 1 google.com &>/dev/null 2>&1; then
echo "You must have an internet connection with working DNS to check for updates."
exit 0
fi
}

check_for_upgrade() {
Expand All @@ -126,17 +131,31 @@ check_for_upgrade() {
echo ""
echo "Please do not power off the device!"
curl -sL https://downloads.hak5.org/api/devices/sharkjack/firmwares/$remote_version-stable -o "/tmp/upgrade-$remote_version.bin"
execute_upgrade
status=$?
if [ $status -eq 0 ]; then
execute_upgrade
else
echo "failed to fetch upgrade file"
exit 1
fi
else
echo "Your device is up-to-date."
exit 0
fi
}

update_time() {
echo "Ensuring system time is correct"

ntpd -q -p 1.openwrt.pool.ntp.org
}

main() {
echo "Checking internet connection"
check_for_internet

update_time

check_for_upgrade
}

Expand Down
28 changes: 23 additions & 5 deletions usr/bin/UPDATE_PAYLOADS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ check_for_internet() {
echo "You must have an internet connection to sync the payload libraries."
exit 0
fi

if ! ping -q -c 1 -W 1 google.com &>/dev/null 2>&1; then
echo "You must have an internet connection with working DNS to check for updates."
exit 0
fi
}

cleanup_tmp() {
Expand All @@ -19,19 +24,32 @@ update_payloads() {

echo "Downloading payloads repository..."
curl -sL $MASTER_URL -o /tmp/payloads-sync.tar.gz
status=$?
if [ $status -eq 0 ]; then
mkdir /tmp/payloads-sync
tar -xzf /tmp/payloads-sync.tar.gz -C /tmp/payloads-sync

mkdir /tmp/payloads-sync
tar -xzf /tmp/payloads-sync.tar.gz -C /tmp/payloads-sync
cp -r /tmp/payloads-sync/sharkjack-payloads-master/payloads/library /root/payload/

cp -r /tmp/payloads-sync/sharkjack-payloads-master/payloads/library /root/payload/
cleanup_tmp

cleanup_tmp
echo "Successfully syncronized payloads repository."
else
echo "failed to fetch payloads"
exit 1
fi
}

echo "Successfully syncronized payloads repository."
update_time() {
echo "Ensuring system time is correct"

ntpd -q -p 1.openwrt.pool.ntp.org
}


main() {
check_for_internet
update_time
update_payloads
}

Expand Down