Partition and format HFS/FAT volumes in the Web UI + SMB install (#946)

- New "format as" option when creating new images; removing the image creation options from easyinstall
- Bring in HFSer as new submodule providing the driver binaries; removing the Lido driver binary from this repo
- Add SpeedTools driver option
- Point to github mirror of hfdisk, since the original git server is down
- While rearranging the easyinstall options, moved the CtrlBoard option up to the main section
- Add an easyinstall script to configure Samba, while consolidating file sharing with Netatalk
This commit is contained in:
Daniel Markstedt
2022-11-01 16:43:24 -07:00
committed by GitHub
parent 9a4f433baf
commit 85edd50047
10 changed files with 534 additions and 159 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ import rascsi.common_settings
WEB_DIR = getcwd()
HOME_DIR = "/".join(WEB_DIR.split("/")[0:3])
AFP_DIR = f"{HOME_DIR}/afpshare"
FILE_SERVER_DIR = f"{HOME_DIR}/shared_files"
MAX_FILE_SIZE = getenv("MAX_FILE_SIZE", str(1024 * 1024 * 1024 * 4)) # 4gb
+25 -6
View File
@@ -439,7 +439,7 @@
<ul>
<li>{{ _("The largest file size accepted in this form is %(max_file_size)s MiB. Use other file transfer means for larger files.", max_file_size=max_file_size) }}</li>
<li>{{ _("File uploads will progress only if you stay on this page. If you navigate away before the transfer is completed, you will end up with an incomplete file.") }}</li>
<li>{{ _("Install <a href=\"%(url)s\" target=\"_blank\">Netatalk</a> to use the AFP File Server.", url="https://github.com/akuker/RASCSI/wiki/AFP-File-Sharing") }}</li>
<li>{{ _("Install Netatalk or Samba to use the File Server.") }}</li>
</ul>
</details>
@@ -447,8 +447,8 @@
<p>
<label for="upload_destination">{{ _("Target directory:") }}</label>
<select name="destination" id="upload_destination">
<option value="images">Images - {{ env["image_dir"] }}</option>
<option value="afp">AppleShare - {{ AFP_DIR }}</option>
<option value="images">{{ _("Disk Images") }} - {{ env["image_dir"] }}</option>
<option value="file_server">{{ _("File Server") }} - {{ FILE_SERVER_DIR }}</option>
</select>
</p>
</form>
@@ -489,15 +489,15 @@
{{ _("Download File from the Web") }}
</summary>
<ul>
<li>{{ _("Install <a href=\"%(url)s\" target=\"_blank\">Netatalk</a> to use the AFP File Server.", url="https://github.com/akuker/RASCSI/wiki/AFP-File-Sharing") }}</li>
<li>{{ _("Install Netatalk or Samba to use the File Server.") }}</li>
</ul>
</details>
<form action="/files/download_url" method="post">
<label for="download_destination">{{ _("Target directory:") }}</label>
<select name="destination" id="download_destination">
<option value="images">Images - {{ env["image_dir"] }}</option>
<option value="afp">AppleShare - {{ AFP_DIR }}</option>
<option value="images">{{ _("Disk Images") }} - {{ env["image_dir"] }}</option>
<option value="file_server">{{ _("File Server") }} - {{ FILE_SERVER_DIR }}</option>
</select>
<label for="download_url">{{ _("URL:") }}</label>
<input name="url" id="download_url" required="" type="url">
@@ -560,6 +560,7 @@
</summary>
<ul>
<li>{{ _("Please refer to <a href=\"%(url)s\" target=\"_blank\">wiki documentation</a> to learn more about the supported image file types.", url="https://github.com/akuker/RASCSI/wiki/Supported-Device-Types#image-types") }}</li>
<li>{{ _("It is not recommended to use the Lido hard disk driver with the Macintosh Plus.") }}</li>
</ul>
</details>
@@ -587,6 +588,24 @@
</option>
{% endfor %}
</select>
<label for="drive_format">{{ _("Format as:") }}</label>
<select name="drive_format" id="drive_format">
<option value="">
{{ _("None") }}
</option>
<option value="Lido 7.56">
HFS + Lido
</option>
<option value="SpeedTools 3.6">
HFS + SpeedTools
</option>
<option value="FAT16">
FAT16
</option>
<option value="FAT32">
FAT32
</option>
</select>
<input type="submit" value="{{ _("Create") }}">
</form>
+76 -8
View File
@@ -59,7 +59,7 @@ from web_utils import (
)
from settings import (
WEB_DIR,
AFP_DIR,
FILE_SERVER_DIR,
MAX_FILE_SIZE,
DEFAULT_CONFIG,
DRIVE_PROPERTIES_FILE,
@@ -251,7 +251,7 @@ def index():
drive_properties=format_drive_properties(APP.config["RASCSI_DRIVE_PROPERTIES"]),
RESERVATIONS=RESERVATIONS,
CFG_DIR=CFG_DIR,
AFP_DIR=AFP_DIR,
FILE_SERVER_DIR=FILE_SERVER_DIR,
PROPERTIES_SUFFIX=PROPERTIES_SUFFIX,
ARCHIVE_FILE_SUFFIXES=ARCHIVE_FILE_SUFFIXES,
CONFIG_FILE_SUFFIX=CONFIG_FILE_SUFFIX,
@@ -864,8 +864,8 @@ def download_file():
"""
destination = request.form.get("destination")
url = request.form.get("url")
if destination == "afp":
destination_dir = AFP_DIR
if destination == "file_server":
destination_dir = FILE_SERVER_DIR
else:
server_info = ractl_cmd.get_server_info()
destination_dir = server_info["image_dir"]
@@ -895,8 +895,8 @@ def upload_file():
return make_response(auth["msg"], 403)
destination = request.form.get("destination")
if destination == "afp":
destination_dir = AFP_DIR
if destination == "file_server":
destination_dir = FILE_SERVER_DIR
else:
server_info = ractl_cmd.get_server_info()
destination_dir = server_info["image_dir"]
@@ -913,6 +913,7 @@ def create_file():
size = (int(request.form.get("size")) * 1024 * 1024)
file_type = request.form.get("type")
drive_name = request.form.get("drive_name")
drive_format = request.form.get("drive_format")
safe_path = is_safe_path(file_name)
if not safe_path["status"]:
@@ -922,6 +923,68 @@ def create_file():
if not process["status"]:
return response(error=True, message=process["msg"])
message_postfix = ""
# Formatting and injecting driver, if one is choosen
if drive_format:
volume_name = f"HD {size / 1024 / 1024:0.0f}M"
known_formats = [
"Lido 7.56",
"SpeedTools 3.6",
"FAT16",
"FAT32",
]
message_postfix = f" ({drive_format})"
if drive_format not in known_formats:
return response(
error=True,
message=_(
"%(drive_format)s is not a valid hard disk format.",
drive_format=drive_format,
)
)
elif drive_format.startswith("FAT"):
if drive_format == "FAT16":
fat_size = "16"
elif drive_format == "FAT32":
fat_size = "32"
else:
return response(
error=True,
message=_(
"%(drive_format)s is not a valid hard disk format.",
drive_format=drive_format,
)
)
process = file_cmd.partition_disk(full_file_name, volume_name, "FAT")
if not process["status"]:
return response(error=True, message=process["msg"])
process = file_cmd.format_fat(
full_file_name,
# FAT volume labels are max 11 chars
volume_name[:11],
fat_size,
)
if not process["status"]:
return response(error=True, message=process["msg"])
else:
driver_base_path = Path(f"{WEB_DIR}/../../../mac-hard-disk-drivers")
process = file_cmd.partition_disk(full_file_name, volume_name, "HFS")
if not process["status"]:
return response(error=True, message=process["msg"])
process = file_cmd.format_hfs(
full_file_name,
volume_name,
driver_base_path / Path(drive_format.replace(" ", "-") + ".img"),
)
if not process["status"]:
return response(error=True, message=process["msg"])
# Creating the drive properties file, if one is chosen
if drive_name:
properties = get_properties_by_drive_name(
@@ -937,15 +1000,20 @@ def create_file():
return response(
status_code=201,
message=_(
"Image file with properties created: %(file_name)s",
"Image file with properties created: %(file_name)s%(drive_format)s",
file_name=full_file_name,
drive_format=message_postfix,
),
image=full_file_name,
)
return response(
status_code=201,
message=_("Image file created: %(file_name)s", file_name=full_file_name),
message=_(
"Image file created: %(file_name)s%(drive_format)s",
file_name=full_file_name,
drive_format=message_postfix,
),
image=full_file_name,
)