2023-11-10 20:51:33 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-11-15 21:01:07 -06:00
|
|
|
set -o
|
|
|
|
set -x
|
|
|
|
set -u
|
|
|
|
|
|
|
|
OS_NAME=$(uname -s)
|
|
|
|
|
|
|
|
if [[ "$OS_NAME" == "Darwin" ]]; then
|
|
|
|
echo "The operating system is macOS."
|
|
|
|
if command -v brew >/dev/null 2>&1; then
|
|
|
|
echo "Homebrew is already installed."
|
|
|
|
else
|
|
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
|
|
fi
|
|
|
|
brew install cmake
|
|
|
|
brew install pkgconfig
|
2023-11-17 20:58:09 -06:00
|
|
|
brew install git
|
2023-11-15 21:01:07 -06:00
|
|
|
elif [[ "$OS_NAME" == "Linux" ]]; then
|
2023-11-17 20:35:48 -06:00
|
|
|
echo "The operating system is Linux."
|
|
|
|
echo "Installing dependencies: cmake and pkgconfig"
|
|
|
|
sudo wget -O /usr/local/bin/pacapt https://github.com/icy/pacapt/raw/ng/pacapt
|
|
|
|
sudo chmod 755 /usr/local/bin/pacapt
|
|
|
|
sudo ln -sv /usr/local/bin/pacapt /usr/local/bin/pacman || true
|
|
|
|
sudo /usr/local/bin/pacapt -S cmake pkg-config git
|
|
|
|
echo "Removing temporary files"
|
|
|
|
sudo rm /usr/local/bin/pacapt
|
|
|
|
sudo rm /usr/local/bin/pacman
|
2023-11-15 21:01:07 -06:00
|
|
|
else
|
|
|
|
echo "Unknown operating system: $OS_NAME"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create a virtual environment
|
2023-11-10 20:51:33 -06:00
|
|
|
mkdir -p ~/.venv
|
2023-11-17 20:35:48 -06:00
|
|
|
python3 -m venv ~/.venv/pypush
|
2023-11-10 20:51:33 -06:00
|
|
|
source ~/.venv/pypush/bin/activate
|
|
|
|
|
|
|
|
# Clone the repo
|
2023-11-15 21:01:07 -06:00
|
|
|
cd ~
|
2023-11-20 20:45:43 -06:00
|
|
|
git clone -b sms-registration https://github.com/beeper/pypush
|
2023-11-10 20:51:33 -06:00
|
|
|
cd pypush
|
|
|
|
|
2023-11-17 20:35:48 -06:00
|
|
|
# Install dependencies
|
|
|
|
pip install -r requirements.txt
|
|
|
|
|
2023-11-10 20:51:33 -06:00
|
|
|
# Prompt the user for the IP address of their phone.
|
2023-11-17 20:35:48 -06:00
|
|
|
read -p "Enter the IP address of your phone(displayed in the Android helper app): " PHONEIP
|
2023-11-10 20:51:33 -06:00
|
|
|
|
|
|
|
# Execute the `python demo.py` script with the phone IP address passed as a parameter.
|
2023-11-17 20:35:48 -06:00
|
|
|
python3 demo.py --phone $PHONEIP
|
2023-11-10 20:51:33 -06:00
|
|
|
|
|
|
|
# Create a reregistration script
|
|
|
|
cat > reregister.sh <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
cd ~/pypush
|
|
|
|
source ~/.venv/pypush/bin/activate
|
2023-11-15 21:01:07 -06:00
|
|
|
while true
|
|
|
|
do
|
2023-11-17 20:35:48 -06:00
|
|
|
python3 ./demo.py --daemon
|
2023-11-15 21:01:07 -06:00
|
|
|
# If it disconnects, wait 5 minutes before reconnecting to avoid spamming servers
|
|
|
|
sleep 300
|
|
|
|
done
|
2023-11-10 20:51:33 -06:00
|
|
|
EOF
|
|
|
|
|
|
|
|
# Make the file executable
|
|
|
|
chmod +x reregister.sh
|