Skip to content

Commit

Permalink
Check if storage has been set up
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiah-k committed Oct 18, 2024
1 parent c23b4d2 commit f44f3dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ Fetchtastic is a tool to download the latest Meshtastic Android app and Firmware
3. **Install Termux API**: Download and install [Termux API](https://f-droid.org/en/packages/com.termux.api/) from F-Droid.
4. *(Optional)* **Install ntfy**: Download and install [ntfy](https://f-droid.org/en/packages/io.heckel.ntfy/) from F-Droid.

### Setup Termux Storage Access

Open Termux and run the following command to grant storage access:

```bash
termux-setup-storage
```

"Allow" when prompted, then restart Termux to apply the changes.

## Installation

### Step 1: Install Dependencies
Expand Down
32 changes: 13 additions & 19 deletions app/setup_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,27 @@ def config_exists():
return os.path.exists(CONFIG_FILE)

def check_storage_setup():
# Check if storage has been set up in Termux by verifying ~/storage directory
# Check if the Termux storage directory and Downloads are set up and writable
storage_dir = os.path.expanduser("~/storage")
if not os.path.exists(storage_dir):
storage_downloads = os.path.expanduser("~/storage/downloads")

# If ~/storage or ~/storage/downloads doesn't exist or isn't writable, exit
if not os.path.exists(storage_dir) or not os.path.exists(storage_downloads) or not os.access(storage_downloads, os.W_OK):
print("Storage access is required to continue.")
print("We will now run a command to enable storage access.")
print("Please allow storage permissions in the upcoming popup.")
confirm = input("Proceed with setting up storage? [y/n] (default: yes): ").strip().lower() or 'y'
if confirm == 'y':
try:
# Run the termux-setup-storage command
subprocess.run(['termux-setup-storage'], check=True)
print("Storage access has been successfully configured. Please restart Termux if needed.")
except Exception as e:
print(f"An error occurred while setting up storage: {e}")
return False
else:
print("Storage setup is required to proceed. Exiting setup.")
return False
print("Please run 'termux-setup-storage' and restart Termux before running this setup again.")
exit() # Exit the script as storage is not set up
print("Storage access has been successfully verified.")
return True

def run_setup():
print("Running Fetchtastic Setup...")

# First, check if Termux storage has been set up
if is_termux() and not check_storage_setup():
print("Setup cannot continue without proper storage access.")
return


# The rest of your setup process continues here
print("Running Fetchtastic Setup...")

if not os.path.exists(DEFAULT_CONFIG_DIR):
os.makedirs(DEFAULT_CONFIG_DIR)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = fetchtastic
version = 0.1.4
version = 0.1.5
author = Jeremiah K
author_email = [email protected]
description = Meshtastic Firmware and APK Downloader
Expand Down

0 comments on commit f44f3dc

Please sign in to comment.