-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
114 lines (97 loc) · 3.67 KB
/
Copy pathconfig.py
File metadata and controls
114 lines (97 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""
ZeroCD Configuration
"""
import os
import uuid
# Display pins (ST7789 1.3" HAT)
DISPLAY_PINS = {
'mosi': 10,
'sclk': 11,
'ce0': 8,
'dc': 25,
'rst': 27,
'bl': 24,
}
# Joystick pins
JOYSTICK_PINS = {
'up': 6,
'down': 19,
'left': 5,
'right': 26,
'press': 13,
'key1': 21, # Additional buttons on HAT
'key2': 20,
'key3': 16,
}
# Display dimensions
DISPLAY_WIDTH = 240
DISPLAY_HEIGHT = 240
# ISO storage
ISO_DIR = "/mnt/iso_storage"
# USB Gadget configuration
GADGET_DIR = "/sys/kernel/config/usb_gadget/zerocd"
GADGET_UDC = None
# DVD gadget: images larger than this sector count (~900 MB) use f_dvd_storage
# 450000 sectors × 2048 bytes = 921,600,000 bytes ≈ 900 MB
DVD_SECTOR_THRESHOLD = 450000
# f_dvd_storage INQUIRY identity (configfs attrs)
# Lengths per SPC-5: vendor=8, product=16, revision=4, serial=20
DVD_VENDOR = "PIONEER" # 8 chars max, blank-padded by module
DVD_PRODUCT = "BDR-X13" # 16 chars max
DVD_REVISION = "1.00" # 4 chars max
DVD_SERIAL = "01234567890123456789" # 20 chars max
# Network interfaces
WIFI_INTERFACE = "wlan0"
USB_ETHERNET_INTERFACE = "usb0"
USB_ETHERNET_IP = "192.168.7.1"
HOST_IP = "192.168.7.2"
# WiFi AP settings
WIFI_AP_SSID_PREFIX = "ZeroCD"
WIFI_AP_CHANNEL = 6
WIFI_AP_IP = "192.168.4.1"
WIFI_AP_DHCP_START = "192.168.4.10"
WIFI_AP_DHCP_END = "192.168.4.50"
# WebUI settings
WEBUI_PORT = 8080
WEBUI_HOST = "0.0.0.0"
WEBUI_SECRET_KEY = os.environ.get("ZEROCD_SECRET_KEY", str(uuid.uuid4()))
# ZeroCD data directory
ZEROCD_DATA_DIR = "/opt/zerocd"
WIFI_NETWORKS_FILE = os.path.join(ZEROCD_DATA_DIR, "wifi_networks.json")
WEBUI_AUTH_FILE = os.path.join(ZEROCD_DATA_DIR, "webui_auth.json")
WEBUI_SESSION_SECRET = os.path.join(ZEROCD_DATA_DIR, ".webui_session_secret")
# Logging
LOG_FILE = "zerocd.log"
JOYSTICK_POLL_RATE = 50
MENU_ITEMS_PER_PAGE = 5
BACKLIGHT_TIMEOUT_SECONDS = 120
BACKLIGHT_FADE_STEPS = 20
BACKLIGHT_FADE_STEP_MS = 50
PRESET_IMG_SIZES = [
{"label": "128 MB", "mb": 128},
{"label": "256 MB", "mb": 256},
{"label": "512 MB", "mb": 512},
{"label": "1 GB", "mb": 1024},
{"label": "2 GB", "mb": 2048},
{"label": "4 GB", "mb": 4096},
{"label": "8 GB", "mb": 8192},
]
# Popular ISO URLs for download
POPULAR_ISOS = [
{"name": "Ubuntu Desktop 22.04", "url": "https://releases.ubuntu.com/22.04/ubuntu-22.04.3-desktop-amd64.iso", "size": "4.2GB"},
{"name": "Ubuntu Desktop 24.04", "url": "https://releases.ubuntu.com/24.04/ubuntu-24.04-desktop-amd64.iso", "size": "4.7GB"},
{"name": "Debian 12 Live", "url": "https://cdimage.debian.org/debian-cd/12.7.0 live/amd64/iso-hybrid/debian-live-12.7.0-amd64-desktop.iso", "size": "3.2GB"},
{"name": "Fedora Workstation 40", "url": "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Workstation/x86_64/iso/Fedora-Workstation-40-1.6.0-x86_64.iso", "size": "2.2GB"},
{"name": "Arch Linux", "url": "https://mirror.rackspace.com/archlinux/iso/2024.03.01/archlinux-2024.03.01-x86_64.iso", "size": "1.1GB"},
{"name": "Kali Linux", "url": "https://cdimage.kali.org/kali-2024.1/kali-linux-2024.1-live-amd64.iso", "size": "4.3GB"},
{"name": "Linux Mint 21", "url": "https://mirror.mintlinuxaustralia.org.uk/release/linuxmint-21.3/linuxmint-21.3-cinnamon-64bit.iso", "size": "2.5GB"},
{"name": "Netboot.xyz", "url": "https://boot.netboot.xyz/ipxe/netboot.xyz-multiarch.iso", "size": "80MB"},
]
# Check if running in USB Gadget mode
def is_gadget_mode() -> bool:
"""Check if USB gadget is active (device mode)."""
return os.path.exists(GADGET_DIR)
# Ensure data directory exists
def ensure_data_dir():
"""Create data directory if it doesn't exist."""
os.makedirs(ZEROCD_DATA_DIR, exist_ok=True)