mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2025-01-09 17:33:47 +00:00
added macos/linux check and OS specifics
This commit is contained in:
parent
a8f6a44c45
commit
846297f477
1 changed files with 32 additions and 10 deletions
|
@ -1,32 +1,54 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
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
|
||||||
|
elif [[ "$OS_NAME" == "Linux" ]]; then
|
||||||
|
echo "The operating system is Linux."
|
||||||
|
else
|
||||||
|
echo "Unknown operating system: $OS_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create a virtual environment
|
||||||
mkdir -p ~/.venv
|
mkdir -p ~/.venv
|
||||||
python3.10 -m pypush ~/.venv
|
python3.10 -m venv ~/.venv/pypush
|
||||||
source ~/.venv/pypush/bin/activate
|
source ~/.venv/pypush/bin/activate
|
||||||
|
|
||||||
# Clone the repo
|
# Clone the repo
|
||||||
|
cd ~
|
||||||
git clone -b sms-registration https://github.com/beeper/pypush
|
git clone -b sms-registration https://github.com/beeper/pypush
|
||||||
cd pypush
|
cd pypush
|
||||||
|
|
||||||
# Change directories to the repository.
|
|
||||||
cd ~/pypush
|
|
||||||
|
|
||||||
# Prompt the user for the IP address of their phone.
|
# Prompt the user for the IP address of their phone.
|
||||||
read -p "Enter the IP address of your phone: " phoneIp
|
read -p "Enter the IP address of your phone: " PHONEIP
|
||||||
|
|
||||||
# Execute the `python demo.py` script with the phone IP address passed as a parameter.
|
# Execute the `python demo.py` script with the phone IP address passed as a parameter.
|
||||||
python demo.py --phone $phoneIp
|
python demo.py --phone $PHONEIP
|
||||||
|
|
||||||
# Create a reregistration script
|
# Create a reregistration script
|
||||||
cat > reregister.sh <<EOF
|
cat > reregister.sh <<EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd ~/pypush
|
cd ~/pypush
|
||||||
source ~/.venv/pypush/bin/activate
|
source ~/.venv/pypush/bin/activate
|
||||||
python ./demo.py --cronreg
|
while true
|
||||||
|
do
|
||||||
|
python ./demo.py --daemon
|
||||||
|
# If it disconnects, wait 5 minutes before reconnecting to avoid spamming servers
|
||||||
|
sleep 300
|
||||||
|
done
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Make the file executable
|
# Make the file executable
|
||||||
chmod +x reregister.sh
|
chmod +x reregister.sh
|
||||||
|
|
||||||
# Add a crontab entry to run every 15 minutes and check registration status
|
|
||||||
crontab -l | { cat; echo "*/15 * * * * ~/pypush/reregister.sh >> /dev/null 2&>1"; } | crontab -
|
|
Loading…
Reference in a new issue