Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

Create an uninstaller and updater, add support for ARM64/AARCH64 update readme and rename MAIN.sh to main.sh #6

Open
wants to merge 8 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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ bash MAIN.sh
- You can access Checkra1n on SSH (port `22` by default, default user/password is `checkra1n`/`checkra1n` and is sudoer for all checkra1n-related executables)

### How to uninstall
`bash MAIN.sh uninstall`
`bash uninstall.sh`

### How to update
`bash update.sh'

## To be done
- [~~Checkra1n Downloader~~ ✅](/checkra1n-downloader/checkra1n-downloader.sh)
- [~~Webra1n Service file~~ ✅](/webra1n.service)
- Access point creator
- [~~user creator for using `checkra1n` over SSH instead of HTTP~~ ✅](/MAIN.sh)
- Raspberry Pi image
- [~~Raspberry Pi image~~ ✅ ]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it done ?


## Warning
- **There is only support for Systemd**
Expand Down
5 changes: 4 additions & 1 deletion checkra1n-downloader/checkra1n-downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ arch=$(uname -m)

if [ "$(echo "$links" | grep "$arch")" ]; then
link=$(echo "$links" | grep "$arch")
else
if arch=aarch64 ; then
arch=arm64
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works but I would prefer the whole script written in the same way, this might look better and more readable:

if [ "$arch" = "aarch64" ]; then
  arch="arm64"

else
fatal "Looks like we can't download checkra1n for you architecture ($arch)"
fi

fi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to add a fi

link=$(echo "$links" | grep "$arch")
# here we have the link corresponding to machine's arch

Expand Down
2 changes: 1 addition & 1 deletion MAIN.sh → main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ else
echo "The only accepted arguments are:"
echo "install - To install webra1n"
echo "unistall - To remove webra1n"
fi
fi
23 changes: 23 additions & 0 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Lloir - 2020 - (github:Lloir)
# This script is part of Webra1n As a Service (github:jusdepatate/webra1n-as-a-service)

systemctl stop webra1n
systemctl disable webra1n
rm /etc/systemd/system/webra1n.service
systemctl daemon-reload
# remove systemd service

cp /etc/sudoers.beforewebra1n /etc/sudoers || fatal "Couldn't use /etc/sudoers backup"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fatal() is a function I created in the original, as it's declared not in this file, calling it like this won't work.
Also crashing an uninstaller for such a reason doesnt seem a good idea to me

deluser checkra1n
# remove checkra1n user

rm /usr/bin/checkra1n
rm /usr/bin/webra1n
rm /usr/bin/checkra1nunkillable
# remove compilated executable from PATH

rm checkra1n
rm checkra1nunkillable/checkra1nunkillable
rm webra1nlauncher/webra1n
# remove compilated executable from here
27 changes: 27 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Lloir - 2020 - (github:Lloir)
# This script is part of Webra1n As a Service (github:jusdepatate/webra1n-as-a-service)

# Stop services prior to update
systemctl stop webra1n
systemctl disable webra1n

# Remove the older binaries

rm /usr/bin/checkra1n
rm /usr/bin/webra1n
rm /usr/bin/checkra1nunkillable

./checkra1n-downloader/checkra1n-downloader.sh || fatal "Checkra1n-Download.sh failed"
chmod +x checkra1n || fatal "Looks like we can't edit permissions of checkra1n executable"
cp checkra1n /usr/bin/checkra1n || fatal "Couldn't move checkra1n in /usr/bin"

# Recompile webra1n
gcc webra1nlauncher/webra1nlauncher.c -o webra1nlauncher/webra1n || fatal "webra1nlauncher compilation failed"
chmod +x webra1nlauncher/webra1n || fatal "Looks like we can't edit permissions of webra1n launcher"
cp webra1nlauncher/webra1n /usr/bin/webra1n || fatal "Couldn't move webra1n in /usr/bin"

# Restart everything
systemctl daemon-reload
systemctl enable webra1n
systemctl start webra1n