-
Notifications
You must be signed in to change notification settings - Fork 3
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 macos install #67
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
58960ab
update shell path and some docs
cooperq 1827068
download ADB if not present
cooperq 877dac8
big O not little o
cooperq bbf2d8b
bugfix
cooperq dc39f2a
bugfix
cooperq 893f5d6
silence errors for macos developers
cooperq b34a97b
Update dist/install-common.sh
cooperq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
#!/bin/env bash | ||
#!/usr/bin/env bash | ||
install() { | ||
if [[ -z "${SERIAL_PATH}" ]]; then | ||
echo "SERIAL_PATH not set, did you run this from install-linux.sh or install-mac.sh?" | ||
echo "\$SERIAL_PATH not set, did you run this from install-linux.sh or install-mac.sh?" | ||
exit 1 | ||
fi | ||
if [[ -z "${ADB}" ]]; then | ||
echo "\$ADB not set, did you run this from install-linux.sh or install-mac.sh?" | ||
exit 1 | ||
fi | ||
check_adb | ||
force_debug_mode | ||
setup_rootshell | ||
setup_rayhunter | ||
test_rayhunter | ||
} | ||
|
||
check_adb() { | ||
if ! command -v adb &> /dev/null | ||
then | ||
echo "adb not found, please ensure it's installed or check the README.md" | ||
exit 1 | ||
fi | ||
} | ||
|
||
force_debug_mode() { | ||
echo "Using adb at $ADB" | ||
echo "Force a switch into the debug mode to enable ADB" | ||
"$SERIAL_PATH" --root | ||
echo -n "adb enabled, waiting for reboot..." | ||
|
@@ -31,14 +27,14 @@ force_debug_mode() { | |
} | ||
|
||
wait_for_atfwd_daemon() { | ||
until [ -n "$(adb shell 'pgrep atfwd_daemon')" ] | ||
until [ -n "$($ADB shell 'pgrep atfwd_daemon)'" ] | ||
do | ||
sleep 1 | ||
done | ||
} | ||
|
||
wait_for_adb_shell() { | ||
until adb shell true 2> /dev/null | ||
until $ADB shell true 2> /dev/null | ||
do | ||
sleep 1 | ||
done | ||
|
@@ -51,29 +47,29 @@ setup_rootshell() { | |
"$SERIAL_PATH" "AT+SYSCMD=chown root /bin/rootshell" | ||
sleep 1 | ||
"$SERIAL_PATH" "AT+SYSCMD=chmod 4755 /bin/rootshell" | ||
adb shell /bin/rootshell -c id | ||
$ADB shell /bin/rootshell -c id | ||
echo "we have root!" | ||
} | ||
|
||
_adb_push() { | ||
adb push "$(dirname "$0")/$1" "$2" | ||
$ADB push "$(dirname "$0")/$1" "$2" | ||
} | ||
|
||
setup_rayhunter() { | ||
adb shell '/bin/rootshell -c "mkdir -p /data/rayhunter"' | ||
$ADB shell '/bin/rootshell -c "mkdir -p /data/rayhunter"' | ||
_adb_push config.toml.example /data/rayhunter/config.toml | ||
_adb_push rayhunter-daemon /data/rayhunter/ | ||
_adb_push scripts/rayhunter_daemon /tmp/rayhunter_daemon | ||
_adb_push scripts/misc-daemon /tmp/misc-daemon | ||
adb shell '/bin/rootshell -c "cp /tmp/rayhunter_daemon /etc/init.d/rayhunter_daemon"' | ||
adb shell '/bin/rootshell -c "cp /tmp/misc-daemon /etc/init.d/misc-daemon"' | ||
adb shell '/bin/rootshell -c "chmod 755 /etc/init.d/rayhunter_daemon"' | ||
adb shell '/bin/rootshell -c "chmod 755 /etc/init.d/misc-daemon"' | ||
$ADB shell '/bin/rootshell -c "cp /tmp/rayhunter_daemon /etc/init.d/rayhunter_daemon"' | ||
$ADB shell '/bin/rootshell -c "cp /tmp/misc-daemon /etc/init.d/misc-daemon"' | ||
$ADB shell '/bin/rootshell -c "chmod 755 /etc/init.d/rayhunter_daemon"' | ||
$ADB shell '/bin/rootshell -c "chmod 755 /etc/init.d/misc-daemon"' | ||
echo -n "waiting for reboot..." | ||
adb shell '/bin/rootshell -c reboot' | ||
$ADB shell '/bin/rootshell -c reboot' | ||
|
||
# first wait for shutdown (it can take ~10s) | ||
until ! adb shell true 2> /dev/null | ||
until ! $ADB shell true 2> /dev/null | ||
do | ||
sleep 1 | ||
done | ||
|
@@ -86,7 +82,7 @@ setup_rayhunter() { | |
|
||
test_rayhunter() { | ||
URL="http://localhost:8080" | ||
adb forward tcp:8080 tcp:8080 > /dev/null | ||
$ADB forward tcp:8080 tcp:8080 > /dev/null | ||
echo -n "checking for rayhunter server..." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto here, double quotes would probably be a good idea |
||
|
||
SECONDS=0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
#!/bin/env bash | ||
|
||
set -e | ||
if ! command -v adb &> /dev/null; then | ||
if [ ! -d ./platform-tools ] ; then | ||
echo "adb not found, downloading local copy" | ||
curl -O "https://dl.google.com/android/repository/platform-tools-latest-linux.zip" | ||
unzip platform-tools-latest-linux.zip | ||
fi | ||
export ADB="./platform-tools/adb" | ||
else | ||
export ADB=`which adb` | ||
fi | ||
|
||
export SERIAL_PATH="./serial-ubuntu-latest/serial" | ||
. "$(dirname "$0")"/install-common.sh | ||
install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
if ! command -v adb &> /dev/null; then | ||
if [ ! -d ./platform-tools ]; then | ||
echo "adb not found, downloading local copy" | ||
curl -O "https://dl.google.com/android/repository/platform-tools-latest-darwin.zip" | ||
unzip platform-tools-latest-darwin.zip | ||
fi | ||
export ADB="./platform-tools/adb" | ||
else | ||
export ADB=`which adb` | ||
fi | ||
|
||
export SERIAL_PATH="./serial-macos-latest/serial" | ||
. "$(dirname "$0")"/install-common.sh | ||
install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ use std::process::Command; | |
use std::os::unix::process::CommandExt; | ||
use std::env; | ||
|
||
#[cfg(target_arch = "arm")] | ||
use nix::unistd::Gid; | ||
|
||
fn main() { | ||
|
@@ -14,11 +15,13 @@ fn main() { | |
// Android's "paranoid network" feature restricts network access to | ||
// processes in specific groups. More info here: | ||
// https://www.elinux.org/Android_Security#Paranoid_network-ing | ||
#[cfg(target_arch = "arm")] { | ||
let gids = &[ | ||
Gid::from_raw(3003), // AID_INET | ||
Gid::from_raw(3004), // AID_NET_RAW | ||
]; | ||
nix::unistd::setgroups(gids).expect("setgroups failed"); | ||
Comment on lines
19
to
23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indent |
||
} | ||
|
||
// discard argv[0] | ||
let _ = args.next(); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's usually good practice to wrap variables-in-commands in double quotes, otherwise all manner of chaos can happen if a space or
*
get into the variable. instead of find/replacing all instances ofadb
with$ADB
, might be easier to make a_adb_shell
function like i did with_adb_push