Below is a complete bash script for installing Void Linux with MUSL, configured according to your specifications. This script assumes you are running it from a live Void Linux MUSL environment (e.g., booted from a Void MUSL live ISO). The script handles the following:
Disk Layout: MBR partition table, 100MB boot partition (ext2), and the rest for an encrypted root partition (XFS) using LUKS2.
Encryption: LUKS2 for the root partition.
Desktop Environment: Sway (Wayland compositor) and Waybar (status bar), fully configured with basic settings. No XWayland, Xorg, GNOME, KDE, or WiFi-related packages are installed or configured.
Applications: Firefox installed with hardened security and privacy settings (via a custom user.js file). Foot is installed as the terminal emulator.
Wayland Only: The system is configured to boot into Wayland with greetd as the display manager, starting Sway automatically. No X11 or related components are included.
Networking: Only basic wired networking is supported using dhcpcd. WiFi is explicitly avoided by not installing any WiFi-related tools or services.
File System: 100MB boot partition as ext2, rest as XFS on the LUKS-encrypted device.
Bootloader: GRUB with LUKS support.
User Creation: A non-root user is created with sudo access.
Security: LUKS encryption, Firefox privacy hardening, and minimal system setup.
Important Notes:
Run this script as root in a Void Linux MUSL live environment.
The script will prompt for inputs (e.g., disk device, passwords). Be careful with disk selection, as this will erase all data on the chosen disk.
Ensure your live environment has internet access, as the script uses xbps-install to download packages.
This script uses sfdisk for partitioning, cryptsetup for LUKS, and xbps-install for package management. It assumes the live environment is MUSL-based, so packages installed will be MUSL variants.
After the script finishes, reboot the system. You will need to enter the LUKS password at boot to unlock the root partition.
The Sway and Waybar configurations are basic. You can customize them later in ~/.config/sway/config and ~/.config/waybar/.
Firefox hardening is applied via a user.js file with privacy-focused preferences. This will be created in the user's home directory.
Script
bash
How to Use the Script
Boot into a Void Linux MUSL live environment (download from the Void Linux website and ensure it's the MUSL variant).
Open a terminal and run the script as root:
bash
sh install_script.sh
(Save the script to a file, e.g., install_script.sh, and make it executable with chmod +x install_script.sh.)
Follow the prompts to enter the disk, passwords, hostname, username, etc.
After the script completes, reboot the system.
At boot, GRUB will load, and you'll be prompted for the LUKS password. After unlocking, greetd will start, and you can log in with the created user. Sway should launch automatically with Waybar configured.
Key Configurations
Sway: Configured with basic keybindings (e.g., Super+Return to open Foot). It's set to use Wayland only.
Waybar: A simple status bar showing workspaces, window title, clock, CPU, memory, and network (wired only, as WiFi is disabled).
Firefox: Hardened with privacy settings like HTTPS-only mode, tracking protection, and disabled features. These can be adjusted in ~/.mozilla/firefox/user.js.
Foot: Installed as the default terminal emulator.
Greetd: Configured to use tuigreet as a simple greeter that launches Sway.
No WiFi: Only dhcpcd is installed for wired networking. No WiFi tools or services are present.
This script is designed to be robust but minimal. If you encounter issues, ensure your live environment is up-to-date and has internet access. You can customize the configurations further after installation. If you need modifications, let me know!
Below is the updated installation script based on your request. I've added support for Firejail, AppArmor, and UFW to enhance security. Here's a summary of the changes:
Firejail: Installed and configured to sandbox applications. Specifically, a Sway keybinding is added to launch Firefox under Firejail for better isolation. A basic Firejail profile for Firefox is created to enforce sandboxing.
AppArmor: Installed and enabled as a service. Basic configuration is applied to load default profiles, ensuring AppArmor is active on boot.
UFW: Installed and configured with a basic firewall setup. By default, it denies incoming traffic and allows outgoing traffic. This assumes UFW is available in the Void Linux repositories (if not, you may need to add a community repository or use an alternative like iptables).
Key Updates:
Package Installation: Added firejail, apparmor, and ufw to the list of packages installed via xbps-install.
Configurations:
Firejail: A custom profile for Firefox is created in /etc/firejail/, and Sway is configured to launch Firefox with Firejail using a keybinding (e.g., Super+F).
AppArmor: The AppArmor service is enabled via runit, and a basic command is added to load profiles.
UFW: Basic firewall rules are set (deny incoming, allow outgoing) and UFW is enabled.
Compatibility: Void Linux may not have UFW packaged by default, as it's more common in Debian-based distros. If UFW is not available, the script will fail during installation. In that case, consider using iptables or ensuring the package is installable via XBPS. For now, the script assumes these packages are accessible.
Security Enhancements: These additions complement the existing LUKS encryption and Firefox hardening, providing application sandboxing, mandatory access control, and network firewalling.
The rest of the script remains unchanged, including the Wayland-only setup, no WiFi, and minimal dependencies.
How to Use the Updated Script
Follow the same instructions as before: Boot into a Void Linux MUSL live environment, run the script as root, and provide the required inputs.
After installation, the system will have:
Firejail sandboxing for Firefox (accessible via Sway keybinding).
AppArmor enforcing security policies.
UFW managing the firewall (you can configure it further with ufw status and ufw allow/deny commands post-install).
Reboot and log in as the created user. Use Super+F in Sway to launch a sandboxed Firefox instance.
Here's the complete updated script:
bash
Additional Notes on the Changes:
Firejail Configuration: A simple profile is created for Firefox to drop capabilities, enforce network filtering, and restrict access. The Sway config now includes a keybinding (Super+F) to launch Firefox under Firejail. You can customize Firejail profiles in /etc/firejail/ or use firejail --list to manage sandboxes.
AppArmor Configuration: The script enforces AppArmor profiles for Firefox and loads default profiles. Use aa-status after booting to check AppArmor status and enforce/complain modes.
UFW Configuration: A basic firewall is set up. It denies all incoming traffic by default and allows outgoing. This is minimal; you can add rules later (e.g., sudo ufw allow ssh if you install an SSH server). If UFW fails to install, consider installing iptables and configuring it manually.
Potential Issues:
If any of these packages are not found in the Void Linux repositories, the script will exit with an error. You may need to add a repository or use alternatives (e.g., iptables for firewalling).
AppArmor and Firejail might require kernel modules or additional setup, but Void Linux should handle this with the installed packages.
Testing: Always test the script in a virtual machine first to avoid data loss.
If you encounter any issues or need further customizations, let me know!
Below is the updated installation script based on your request. I've made the following changes:
Prompt for Password: The script already prompts for passwords (LUKS and user). I've retained these prompts but removed the prompt and setting for the root password, as per your "no root user" request.
No Root User: The root account is now locked after installation, preventing direct login. All administrative tasks must be performed via sudo by the created user. This enhances security by eliminating the root user as a login option.
Specifically, the root password is not set, and the root account is locked using passwd -l root.
User Creation: The script still creates a non-root user with sudo access (no password required for sudo, as per the existing NOPASSWD configuration). This user will be the primary account for login and administration.
Other Aspects: The rest of the script remains unchanged, including the LUKS encryption, Wayland-only setup, security tools (Firejail, AppArmor, UFW), and minimal dependencies. The system will boot into greetd, and the user can log in with the created username and password.
Key Updates:
Removed the ROOT_PASS prompt and related commands.
Added a step in the chroot section to lock the root account with passwd -l root.
Ensured that the user has full sudo privileges for administrative tasks.
The LUKS password prompt remains for disk encryption.
After installation, you log in as the created user and use sudo for any root-level operations.
How to Use the Updated Script
Boot into a Void Linux MUSL live environment.
Run the script as root in the live environment.
The script will prompt for the disk, LUKS password, hostname, username, and user password.
After reboot, enter the LUKS password at boot, then log in with the created username and password. Use sudo for administrative tasks (e.g., sudo ufw status).
Sway keybindings (e.g., Super+F for Firejail-sandboxed Firefox) and other configurations remain intact.
Here's the complete updated script:
bash
#!/bin/sh
set -e # Exit on error
# Prompt for user inputs
read -p "Enter the disk to install on (e.g., /dev/sda): " DISK
read -s -p "Enter LUKS encryption password: " LUKS_PASS
echo
read -p "Enter hostname for the new system: " HOSTNAME
read -p "Enter username for a new user: " USERNAME
read -s -p "Enter password for $USERNAME: " USER_PASS
echo
# Validate inputs (basic check)
if [ -z "$DISK" ] || [ -z "$LUKS_PASS" ] || [ -z "$HOSTNAME" ] || [ -z "$USERNAME" ] || [ -z "$USER_PASS" ]; then
echo "All inputs are required. Exiting."
exit 1
fi
# Partition the disk with MBR using sfdisk
echo "Partitioning $DISK with MBR (100MB boot, rest for root)..."
echo -e "label: dos\nsize=100M, type=83\n, type=83" | sfdisk "$DISK"
# Set up LUKS2 encryption on the second partition
echo "Setting up LUKS2 encryption on ${DISK}2..."
echo -n "$LUKS_PASS" | cryptsetup luksFormat --type luks2 "${DISK}2"
echo -n "$LUKS_PASS" | cryptsetup luksOpen "${DISK}2" luksroot
# Format partitions
mkfs.ext2 "${DISK}1" # Boot partition as ext2
mkfs.xfs /dev/mapper/luksroot # Root partition as XFS
# Create and mount file systems
mkdir -p /mnt
mount /dev/mapper/luksroot /mnt
mkdir -p /mnt/boot
mount "${DISK}1" /mnt/boot
# Mount necessary pseudo-filesystems for chroot
mount -t proc none /mnt/proc
mount -t sysfs none /mnt/sys
mount -o bind /dev /mnt/dev
mount -t devpts none /mnt/dev/pts
# Generate fstab and crypttab using UUIDs for persistence
echo "Generating fstab and crypttab..."
BOOT_UUID=$(blkid -s UUID -o value "${DISK}1")
ROOT_UUID=$(blkid -s UUID -o value /dev/mapper/luksroot)
LUKS_UUID=$(blkid -s UUID -o value "${DISK}2")
cat > /mnt/etc/fstab << EOF
UUID=$BOOT_UUID /boot ext2 defaults 0 2
UUID=$ROOT_UUID / xfs defaults 0 1
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
EOF
cat > /mnt/etc/crypttab << EOF
luksroot UUID=$LUKS_UUID none luks,discard
EOF
# Install base system with MUSL (assuming live environment is MUSL)
echo "Installing base system..."
xbps-install -Sy # Update package repository
xbps-install -r /mnt base-system linux5.15 cryptsetup # Install base, kernel, and cryptsetup
# Chroot into the new system and configure
cat << EOF | chroot /mnt /bin/sh
#!/bin/sh
# Set hostname
echo "$HOSTNAME" > /etc/hostname
# Do not set root password; instead, lock the root account
passwd -l root # Lock root account to disable login
# Update package repository and install additional packages, including security tools
xbps-install -Syu
xbps-install grub sway waybar foot firefox greetd tuigreet dhcpcd sudo firejail apparmor ufw
# Avoid WiFi: Do not install networkmanager, wpa_supplicant, or wireless tools
# Only dhcpcd for wired networking is installed and enabled
# Create a non-root user and set password; this user will have sudo access
useradd -m -G wheel,audio,video -s /bin/sh $USERNAME # Use sh as shell for minimalism
echo "$USERNAME:$USER_PASS" | chpasswd
# Set up sudo for wheel group (no password required for sudo)
echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/wheel
# Configure services with runit (enable greetd, dhcpcd, and add AppArmor)
ln -s /etc/sv/greetd /var/service/
ln -s /etc/sv/dhcpcd /var/service/ # Enables wired networking; assumes auto-detection
ln -s /etc/sv/apparmor /var/service/ # Enable AppArmor service
# Configure greetd to start tuigreet, which launches Sway (Wayland only)
cat > /etc/greetd/config.toml << GREETDCONF
[terminal]
vt = 1
[default_session]
command = "tuigreet --time --cmd sway"
user = "greeter"
GREETDCONF
# Configure Sway (basic config, Wayland only, no XWayland; add Firejail binding for Firefox)
mkdir -p /home/$USERNAME/.config/sway
cat > /home/$USERNAME/.config/sway/config << SWAYCONF
# Sway configuration for Wayland only
# Default terminal is foot; add binding for Firejail-sandboxed Firefox
set \$mod Mod4
bindsym \$mod+Return exec foot
bindsym \$mod+Shift+q kill
bindsym \$mod+f exec firejail firefox # Launch Firefox under Firejail sandbox
bindsym \$mod+d exec wofi --show drun # Use wofi as a simple launcher (install wofi if needed)
bindsym \$mod+Shift+c reload
bindsym \$mod+Shift+r restart
bindsym \$mod+space floating toggle
workspace 1
workspace 2
# Add more bindings as needed
include /etc/sway/config.d/*
SWAYCONF
chown $USERNAME:users /home/$USERNAME/.config/sway/config
# Configure Waybar (basic config)
mkdir -p /home/$USERNAME/.config/waybar
cat > /home/$USERNAME/.config/waybar/config.json << WAYBARCONF
{
"layer": "top",
"position": "top",
"modules-left": ["sway/workspaces"],
"modules-center": ["sway/window"],
"modules-right": ["clock", "cpu", "memory", "network"],
"clock": {
"format": "{:%Y-%m-%d %H:%M:%S}"
},
"cpu": {
"format": "CPU: {usage}%"
},
"memory": {
"format": "MEM: {}%"
},
"network": {
"format-wired": "Net: {ifname} {ipaddr}",
"format-wifi": "",
"tooltip-format": "Net: {ifname} via {gwaddr}"
}
}
WAYBARCONF
# Add basic CSS for Waybar styling
cat > /home/$USERNAME/.config/waybar/style.css << WAYBARCSS
* {
border: none;
border-radius: 0;
font-family: monospace;
font-size: 12px;
min-height: 0;
}
window#waybar {
background: rgba(43, 48, 59, 0.5);
color: #ffffff;
}
#workspaces button {
padding: 0 5px;
background: transparent;
color: #ffffff;
}
#clock, #cpu, #memory, #network {
padding: 0 10px;
}
WAYBARCSS
chown -R $USERNAME:users /home/$USERNAME/.config/waybar
# Configure Firefox with hardened security and privacy (create user.js)
mkdir -p /home/$USERNAME/.mozilla/firefox
cat > /home/$USERNAME/.mozilla/firefox/user.js << FIREFOXCONF
// Firefox privacy and security hardening
user_pref("app.update.enabled", false); // Disable automatic updates
user_pref("datareporting.healthreport.uploadEnabled", false); // Disable health report
user_pref("browser.safebrowsing.enabled", true); // Enable malware protection
user_pref("privacy.trackingprotection.enabled", true); // Enable tracking protection
user_pref("privacy.trackingprotection.pbmode.enabled", true); // Enable in private browsing
user_pref("dom.security.https_only_mode", true); // Enforce HTTPS-only
user_pref("browser.privatebrowsing.autostart", true); // Start in private browsing mode
user_pref("signon.rememberSignons", false); // Disable password saving
user_pref("network.cookie.lifetimePolicy", 2); // Clear cookies on exit
user_pref("permissions.default.image", 2); // Block images by default (can be changed)
user_pref("media.eme.enabled", false); // Disable DRM
user_pref("geo.enabled", false); // Disable geolocation
user_pref("webgl.disabled", true); // Disable WebGL for security
user_pref("javascript.options.ion", false); // Disable JIT compiler for security
FIREFOXCONF
chown -R $USERNAME:users /home/$USERNAME/.mozilla/firefox
# Configure Firejail (create a basic profile for Firefox)
mkdir -p /etc/firejail
cat > /etc/firejail/firefox.profile << FIREJAILCONF
# Basic Firejail profile for Firefox
caps.drop all
netfilter
protocol unix,inet,inet6
blacklist /etc /usr /boot /dev /proc /sys
read-only /usr /etc
private-tmp
FIREJAILCONF
# Configure AppArmor (load default profiles and ensure service is running)
aa-enforce /usr/bin/firefox # Enforce AppArmor profile for Firefox if available
aa-enforce -d / # Load all default profiles (can be adjusted)
# Configure UFW (basic firewall setup: deny incoming, allow outgoing)
ufw default deny incoming
ufw default allow outgoing
ufw enable # Enable firewall; this will prompt for confirmation if run interactively, but should work in script
# Set ownership for user's home directory
chown -R $USERNAME:users /home/$USERNAME
# Install and configure GRUB with LUKS support
grub-install --target=i386-pc $DISK # MBR bootloader
grub-mkconfig -o /boot/grub/grub.cfg # Generate GRUB config (should detect LUKS)
EOF
# Unmount file systems and close LUKS
umount /mnt/dev/pts
umount /mnt/dev
umount /mnt/sys
umount /mnt/proc
umount /mnt/boot
umount /mnt
cryptsetup luksClose luksroot
echo "Installation complete with no root user enabled (root account locked)."
echo "Reboot the system now."
echo "After reboot, enter the LUKS password to unlock the root partition."
echo "Log in as the created user with the provided username and password."
echo "Use 'sudo' for administrative tasks. Sway, Waybar, Foot, and security tools are configured as before."
Additional Notes:
Security Implications: By locking the root account, you've increased security, but ensure the created user is trusted, as they have full sudo access without a password prompt. If you want to add a password requirement for sudo, you can edit /etc/sudoers.d/wheel after installation (e.g., remove NOPASSWD).
Testing: As always, test this script in a virtual machine first to avoid data loss. If you need further refinements (e.g., adding password prompts for sudo or other customizations), let me know!
Dataset releases
Not yet included in a published release.
#!/bin/sh
set -e # Exit on error
# Prompt for user inputs
read -p "Enter the disk to install on (e.g., /dev/sda): " DISK
read -s -p "Enter LUKS encryption password: " LUKS_PASS
echo
read -s -p "Enter root password for the new system: " ROOT_PASS
echo
read -p "Enter hostname for the new system: " HOSTNAME
read -p "Enter username for a new user: " USERNAME
read -s -p "Enter password for $USERNAME: " USER_PASS
echo
# Validate inputs (basic check)
if [ -z "$DISK" ] || [ -z "$LUKS_PASS" ] || [ -z "$ROOT_PASS" ] || [ -z "$HOSTNAME" ] || [ -z "$USERNAME" ] || [ -z "$USER_PASS" ]; then
echo "All inputs are required. Exiting."
exit 1
fi
# Partition the disk with MBR using sfdisk
echo "Partitioning $DISK with MBR (100MB boot, rest for root)..."
echo -e "label: dos\nsize=100M, type=83\n, type=83" | sfdisk "$DISK"
# Set up LUKS2 encryption on the second partition
echo "Setting up LUKS2 encryption on ${DISK}2..."
echo -n "$LUKS_PASS" | cryptsetup luksFormat --type luks2 "${DISK}2"
echo -n "$LUKS_PASS" | cryptsetup luksOpen "${DISK}2" luksroot
# Format partitions
mkfs.ext2 "${DISK}1" # Boot partition as ext2
mkfs.xfs /dev/mapper/luksroot # Root partition as XFS
# Create and mount file systems
mkdir -p /mnt
mount /dev/mapper/luksroot /mnt
mkdir -p /mnt/boot
mount "${DISK}1" /mnt/boot
# Mount necessary pseudo-filesystems for chroot
mount -t proc none /mnt/proc
mount -t sysfs none /mnt/sys
mount -o bind /dev /mnt/dev
mount -t devpts none /mnt/dev/pts
# Generate fstab and crypttab using UUIDs for persistence
echo "Generating fstab and crypttab..."
BOOT_UUID=$(blkid -s UUID -o value "${DISK}1")
ROOT_UUID=$(blkid -s UUID -o value /dev/mapper/luksroot)
LUKS_UUID=$(blkid -s UUID -o value "${DISK}2")
cat > /mnt/etc/fstab << EOF
UUID=$BOOT_UUID /boot ext2 defaults 0 2
UUID=$ROOT_UUID / xfs defaults 0 1
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
EOF
cat > /mnt/etc/crypttab << EOF
luksroot UUID=$LUKS_UUID none luks,discard
EOF
# Install base system with MUSL (assuming live environment is MUSL)
echo "Installing base system..."
xbps-install -Sy # Update package repository
xbps-install -r /mnt base-system linux5.15 cryptsetup # Install base, kernel, and cryptsetup
# Chroot into the new system and configure
cat << EOF | chroot /mnt /bin/sh
#!/bin/sh
# Set hostname
echo "$HOSTNAME" > /etc/hostname
# Set root password
echo "root:$ROOT_PASS" | chpasswd
# Update package repository and install additional packages
xbps-install -Syu
xbps-install grub sway waybar foot firefox greetd tuigreet dhcpcd sudo
# Avoid WiFi: Do not install networkmanager, wpa_supplicant, or wireless tools
# Only dhcpcd for wired networking is installed and enabled
# Create a non-root user and set password
useradd -m -G wheel,audio,video -s /bin/sh $USERNAME # Use sh as shell for minimalism
echo "$USERNAME:$USER_PASS" | chpasswd
# Set up sudo for wheel group
echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/wheel
# Configure services with runit (enable greetd and dhcpcd)
ln -s /etc/sv/greetd /var/service/
ln -s /etc/sv/dhcpcd /var/service/ # Enables wired networking; assumes auto-detection
# Configure greetd to start tuigreet, which launches Sway (Wayland only)
cat > /etc/greetd/config.toml << GREETDCONF
[terminal]
vt = 1
[default_session]
command = "tuigreet --time --cmd sway"
user = "greeter" # tuigreet handles user authentication
GREETDCONF
# Configure Sway (basic config, Wayland only, no XWayland)
mkdir -p /home/$USERNAME/.config/sway
cat > /home/$USERNAME/.config/sway/config << SWAYCONF
# Sway configuration for Wayland only
# Default terminal is foot
set \$mod Mod4
bindsym \$mod+Return exec foot
bindsym \$mod+Shift+q kill
bindsym \$mod+d exec wofi --show drun # Use wofi as a simple launcher (install wofi if needed)
bindsym \$mod+Shift+c reload
bindsym \$mod+Shift+r restart
bindsym \$mod+space floating toggle
workspace 1
workspace 2
# Add more bindings as needed
include /etc/sway/config.d/*
SWAYCONF
chown $USERNAME:users /home/$USERNAME/.config/sway/config
# Configure Waybar (basic config)
mkdir -p /home/$USERNAME/.config/waybar
cat > /home/$USERNAME/.config/waybar/config.json << WAYBARCONF
{
"layer": "top",
"position": "top",
"modules-left": ["sway/workspaces"],
"modules-center": ["sway/window"],
"modules-right": ["clock", "cpu", "memory", "network"],
"clock": {
"format": "{:%Y-%m-%d %H:%M:%S}"
},
"cpu": {
"format": "CPU: {usage}%"
},
"memory": {
"format": "MEM: {}%"
},
"network": {
"format-wired": "Net: {ifname} {ipaddr}",
"format-wifi": "",
"tooltip-format": "Net: {ifname} via {gwaddr}"
}
}
WAYBARCONF
# Add basic CSS for Waybar styling
cat > /home/$USERNAME/.config/waybar/style.css << WAYBARCSS
* {
border: none;
border-radius: 0;
font-family: monospace;
font-size: 12px;
min-height: 0;
}
window#waybar {
background: rgba(43, 48, 59, 0.5);
color: #ffffff;
}
#workspaces button {
padding: 0 5px;
background: transparent;
color: #ffffff;
}
#clock, #cpu, #memory, #network {
padding: 0 10px;
}
WAYBARCSS
chown -R $USERNAME:users /home/$USERNAME/.config/waybar
# Configure Firefox with hardened security and privacy (create user.js)
mkdir -p /home/$USERNAME/.mozilla/firefox
cat > /home/$USERNAME/.mozilla/firefox/user.js << FIREFOXCONF
// Firefox privacy and security hardening
user_pref("app.update.enabled", false); // Disable automatic updates
user_pref("datareporting.healthreport.uploadEnabled", false); // Disable health report
user_pref("browser.safebrowsing.enabled", true); // Enable malware protection
user_pref("privacy.trackingprotection.enabled", true); // Enable tracking protection
user_pref("privacy.trackingprotection.pbmode.enabled", true); // Enable in private browsing
user_pref("dom.security.https_only_mode", true); // Enforce HTTPS-only
user_pref("browser.privatebrowsing.autostart", true); // Start in private browsing mode
user_pref("signon.rememberSignons", false); // Disable password saving
user_pref("network.cookie.lifetimePolicy", 2); // Clear cookies on exit
user_pref("permissions.default.image", 2); // Block images by default (can be changed)
user_pref("media.eme.enabled", false); // Disable DRM
user_pref("geo.enabled", false); // Disable geolocation
user_pref("webgl.disabled", true); // Disable WebGL for security
user_pref("javascript.options.ion", false); // Disable JIT compiler for security
FIREFOXCONF
chown -R $USERNAME:users /home/$USERNAME/.mozilla/firefox
# Set ownership for user's home directory
chown -R $USERNAME:users /home/$USERNAME
# Install and configure GRUB with LUKS support
grub-install --target=i386-pc $DISK # MBR bootloader
grub-mkconfig -o /boot/grub/grub.cfg # Generate GRUB config (should detect LUKS)
EOF
# Unmount file systems and close LUKS
umount /mnt/dev/pts
umount /mnt/dev
umount /mnt/sys
umount /mnt/proc
umount /mnt/boot
umount /mnt
cryptsetup luksClose luksroot
echo "Installation complete. Reboot the system now."
echo "After reboot, you will need to enter the LUKS password to unlock the root partition."
echo "Log in as the created user and start using Sway with Waybar and Foot."
#!/bin/sh
set -e # Exit on error
# Prompt for user inputs
read -p "Enter the disk to install on (e.g., /dev/sda): " DISK
read -s -p "Enter LUKS encryption password: " LUKS_PASS
echo
read -s -p "Enter root password for the new system: " ROOT_PASS
echo
read -p "Enter hostname for the new system: " HOSTNAME
read -p "Enter username for a new user: " USERNAME
read -s -p "Enter password for $USERNAME: " USER_PASS
echo
# Validate inputs (basic check)
if [ -z "$DISK" ] || [ -z "$LUKS_PASS" ] || [ -z "$ROOT_PASS" ] || [ -z "$HOSTNAME" ] || [ -z "$USERNAME" ] || [ -z "$USER_PASS" ]; then
echo "All inputs are required. Exiting."
exit 1
fi
# Partition the disk with MBR using sfdisk
echo "Partitioning $DISK with MBR (100MB boot, rest for root)..."
echo -e "label: dos\nsize=100M, type=83\n, type=83" | sfdisk "$DISK"
# Set up LUKS2 encryption on the second partition
echo "Setting up LUKS2 encryption on ${DISK}2..."
echo -n "$LUKS_PASS" | cryptsetup luksFormat --type luks2 "${DISK}2"
echo -n "$LUKS_PASS" | cryptsetup luksOpen "${DISK}2" luksroot
# Format partitions
mkfs.ext2 "${DISK}1" # Boot partition as ext2
mkfs.xfs /dev/mapper/luksroot # Root partition as XFS
# Create and mount file systems
mkdir -p /mnt
mount /dev/mapper/luksroot /mnt
mkdir -p /mnt/boot
mount "${DISK}1" /mnt/boot
# Mount necessary pseudo-filesystems for chroot
mount -t proc none /mnt/proc
mount -t sysfs none /mnt/sys
mount -o bind /dev /mnt/dev
mount -t devpts none /mnt/dev/pts
# Generate fstab and crypttab using UUIDs for persistence
echo "Generating fstab and crypttab..."
BOOT_UUID=$(blkid -s UUID -o value "${DISK}1")
ROOT_UUID=$(blkid -s UUID -o value /dev/mapper/luksroot)
LUKS_UUID=$(blkid -s UUID -o value "${DISK}2")
cat > /mnt/etc/fstab << EOF
UUID=$BOOT_UUID /boot ext2 defaults 0 2
UUID=$ROOT_UUID / xfs defaults 0 1
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
EOF
cat > /mnt/etc/crypttab << EOF
luksroot UUID=$LUKS_UUID none luks,discard
EOF
# Install base system with MUSL (assuming live environment is MUSL)
echo "Installing base system..."
xbps-install -Sy # Update package repository
xbps-install -r /mnt base-system linux5.15 cryptsetup # Install base, kernel, and cryptsetup
# Chroot into the new system and configure
cat << EOF | chroot /mnt /bin/sh
#!/bin/sh
# Set hostname
echo "$HOSTNAME" > /etc/hostname
# Set root password
echo "root:$ROOT_PASS" | chpasswd
# Update package repository and install additional packages, including security tools
xbps-install -Syu
xbps-install grub sway waybar foot firefox greetd tuigreet dhcpcd sudo firejail apparmor ufw
# Avoid WiFi: Do not install networkmanager, wpa_supplicant, or wireless tools
# Only dhcpcd for wired networking is installed and enabled
# Create a non-root user and set password
useradd -m -G wheel,audio,video -s /bin/sh $USERNAME # Use sh as shell for minimalism
echo "$USERNAME:$USER_PASS" | chpasswd
# Set up sudo for wheel group
echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/wheel
# Configure services with runit (enable greetd, dhcpcd, and add AppArmor)
ln -s /etc/sv/greetd /var/service/
ln -s /etc/sv/dhcpcd /var/service/ # Enables wired networking; assumes auto-detection
ln -s /etc/sv/apparmor /var/service/ # Enable AppArmor service
# Configure greetd to start tuigreet, which launches Sway (Wayland only)
cat > /etc/greetd/config.toml << GREETDCONF
[terminal]
vt = 1
[default_session]
command = "tuigreet --time --cmd sway"
user = "greeter"
GREETDCONF
# Configure Sway (basic config, Wayland only, no XWayland; add Firejail binding for Firefox)
mkdir -p /home/$USERNAME/.config/sway
cat > /home/$USERNAME/.config/sway/config << SWAYCONF
# Sway configuration for Wayland only
# Default terminal is foot; add binding for Firejail-sandboxed Firefox
set \$mod Mod4
bindsym \$mod+Return exec foot
bindsym \$mod+Shift+q kill
bindsym \$mod+f exec firejail firefox # Launch Firefox under Firejail sandbox
bindsym \$mod+d exec wofi --show drun # Use wofi as a simple launcher (install wofi if needed)
bindsym \$mod+Shift+c reload
bindsym \$mod+Shift+r restart
bindsym \$mod+space floating toggle
workspace 1
workspace 2
# Add more bindings as needed
include /etc/sway/config.d/*
SWAYCONF
chown $USERNAME:users /home/$USERNAME/.config/sway/config
# Configure Waybar (basic config)
mkdir -p /home/$USERNAME/.config/waybar
cat > /home/$USERNAME/.config/waybar/config.json << WAYBARCONF
{
"layer": "top",
"position": "top",
"modules-left": ["sway/workspaces"],
"modules-center": ["sway/window"],
"modules-right": ["clock", "cpu", "memory", "network"],
"clock": {
"format": "{:%Y-%m-%d %H:%M:%S}"
},
"cpu": {
"format": "CPU: {usage}%"
},
"memory": {
"format": "MEM: {}%"
},
"network": {
"format-wired": "Net: {ifname} {ipaddr}",
"format-wifi": "",
"tooltip-format": "Net: {ifname} via {gwaddr}"
}
}
WAYBARCONF
# Add basic CSS for Waybar styling
cat > /home/$USERNAME/.config/waybar/style.css << WAYBARCSS
* {
border: none;
border-radius: 0;
font-family: monospace;
font-size: 12px;
min-height: 0;
}
window#waybar {
background: rgba(43, 48, 59, 0.5);
color: #ffffff;
}
#workspaces button {
padding: 0 5px;
background: transparent;
color: #ffffff;
}
#clock, #cpu, #memory, #network {
padding: 0 10px;
}
WAYBARCSS
chown -R $USERNAME:users /home/$USERNAME/.config/waybar
# Configure Firefox with hardened security and privacy (create user.js)
mkdir -p /home/$USERNAME/.mozilla/firefox
cat > /home/$USERNAME/.mozilla/firefox/user.js << FIREFOXCONF
// Firefox privacy and security hardening
user_pref("app.update.enabled", false); // Disable automatic updates
user_pref("datareporting.healthreport.uploadEnabled", false); // Disable health report
user_pref("browser.safebrowsing.enabled", true); // Enable malware protection
user_pref("privacy.trackingprotection.enabled", true); // Enable tracking protection
user_pref("privacy.trackingprotection.pbmode.enabled", true); // Enable in private browsing
user_pref("dom.security.https_only_mode", true); // Enforce HTTPS-only
user_pref("browser.privatebrowsing.autostart", true); // Start in private browsing mode
user_pref("signon.rememberSignons", false); // Disable password saving
user_pref("network.cookie.lifetimePolicy", 2); // Clear cookies on exit
user_pref("permissions.default.image", 2); // Block images by default (can be changed)
user_pref("media.eme.enabled", false); // Disable DRM
user_pref("geo.enabled", false); // Disable geolocation
user_pref("webgl.disabled", true); // Disable WebGL for security
user_pref("javascript.options.ion", false); // Disable JIT compiler for security
FIREFOXCONF
chown -R $USERNAME:users /home/$USERNAME/.mozilla/firefox
# Configure Firejail (create a basic profile for Firefox)
mkdir -p /etc/firejail
cat > /etc/firejail/firefox.profile << FIREJAILCONF
# Basic Firejail profile for Firefox
caps.drop all
netfilter
protocol unix,inet,inet6
blacklist /etc /usr /boot /dev /proc /sys
read-only /usr /etc
private-tmp
FIREJAILCONF
# Configure AppArmor (load default profiles and ensure service is running)
aa-enforce /usr/bin/firefox # Enforce AppArmor profile for Firefox if available
aa-enforce -d / # Load all default profiles (can be adjusted)
# Configure UFW (basic firewall setup: deny incoming, allow outgoing)
ufw default deny incoming
ufw default allow outgoing
ufw enable # Enable firewall; this will prompt for confirmation if run interactively, but should work in script
# Set ownership for user's home directory
chown -R $USERNAME:users /home/$USERNAME
# Install and configure GRUB with LUKS support
grub-install --target=i386-pc $DISK # MBR bootloader
grub-mkconfig -o /boot/grub/grub.cfg # Generate GRUB config (should detect LUKS)
EOF
# Unmount file systems and close LUKS
umount /mnt/dev/pts
umount /mnt/dev
umount /mnt/sys
umount /mnt/proc
umount /mnt/boot
umount /mnt
cryptsetup luksClose luksroot
echo "Installation complete with added security tools (Firejail, AppArmor, UFW)."
echo "Reboot the system now."
echo "After reboot, enter the LUKS password to unlock the root partition."
echo "Log in as the created user. Use Super+F in Sway to launch a sandboxed Firefox with Firejail."
echo "UFW is enabled with basic rules; check status with 'sudo ufw status'. AppArmor is active for enhanced security."