Skip to content

Commit

Permalink
WIP Linux and macOS convenience script
Browse files Browse the repository at this point in the history
  • Loading branch information
mrrfv committed May 14, 2023
1 parent 113a655 commit a807130
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions convenience-scripts/linux_mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

echo "Open Android Backup convenience script for Linux and macOS"
echo "This script will install dependencies, download and run the latest release of Open Android Backup."
echo "The script hasn't been fully tested, so feedback is welcome!"
echo ""

warn_untested_os() {
echo "WARNING: This convenience script has not been tested on your operating system. It may not work as expected."
echo "If you encounter any issues, please report them at https://github.com/mrrfv/open-android-backup/issues"
echo "Continuing in 15 seconds..."
sleep 15
}

# Detect OS
if [[ -n "$WSL_DISTRO_NAME" ]]; then
echo "WSL is not supported by the convenience script at this time. Please follow the regular usage instructions at https://github.com/mrrfv/open-android-backup"
exit 1
else
echo "Not running within WSL, continuing..."
fi

echo "Installing dependencies - you may be prompted for your password."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
if which brew >/dev/null 2>&1; then
echo "Homebrew is installed, continuing..."
else
echo "Homebrew is not installed. It is needed to continue. Press Enter to automatically install Homebrew."
read -r # wait for enter key
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install --cask android-platform-tools
brew install p7zip pv bash dialog curl wget unzip
elif [[ -n "$(command -v apt)" ]]; then
# Ubuntu and Debian
sudo apt update && sudo apt install -y p7zip-full adb curl whiptail pv secure-delete wget unzip
elif [[ -n "$(command -v pacman)" ]]; then
# Arch Linux
warn_untested_os
sudo pacman -Syu --noconfirm p7zip curl wget pv bash whiptail adb secure-delete unzip
elif [[ -n "$(command -v dnf)" ]]; then
# Fedora
warn_untested_os
sudo dnf update && sudo dnf install -y p7zip curl wget pv bash whiptail android-tools secure-delete unzip
elif [[ -n "$(command -v zypper)" ]]; then
# openSUSE
warn_untested_os
sudo zypper refresh && sudo zypper install -y p7zip-full curl wget pv bash whiptail android-tools secure-delete unzip
elif [[ -n "$(command -v emerge)" ]]; then
# Gentoo Linux
warn_untested_os
sudo emerge --sync && sudo emerge --ask app-arch/p7zip dev-util/android-tools dev-util/curl net-misc/wget app-arch/unzip app-shells/bash app-misc/dialog app-misc/pv sys-apps/sec
elif [[ -n "$(command -v yum)" ]]; then
# RHEL/CentOS/Oracle Linux/etc.
warn_untested_os
sudo yum update && sudo yum install -y p7zip curl wget pv bash whiptail android-tools secure-delete unzip

else
echo "Unsupported operating system. Follow the regular installation instructions instead."
echo "If you encounter any issues, please report them at https://github.com/mrrfv/open-android-backup/issues"
exit 1
fi

echo "Downloading latest release of Open Android Backup..."
# Download latest release of Open Android Backup and run it.
OAB_DIRECTORY="open_android_backup_conveniencescript_$RANDOM"
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/mrrfv/open-android-backup/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

mkdir -pv $OAB_DIRECTORY &&
cd $OAB_DIRECTORY &&
wget "https://github.com/mrrfv/open-android-backup/releases/download/$LATEST_RELEASE/Open_Android_Backup_${LATEST_RELEASE}_Bundle.zip" &&
unzip "Open_Android_Backup_${LATEST_RELEASE}_Bundle.zip" &&
chmod +x backup.sh &&
echo "Running Open Android Backup..." &&
bash ./backup.sh ;
echo "Cleaning up..." &&
cd .. &&
rm -rf $OAB_DIRECTORY &&
echo "Done!"

0 comments on commit a807130

Please sign in to comment.