2023-11-07 10:06:36 -06:00
2023-11-07 09:03:53 -06:00
2023-11-07 09:03:53 -06:00
2023-11-07 10:06:36 -06:00
2023-11-07 09:03:53 -06:00
2023-11-07 10:06:36 -06:00
2023-11-07 09:03:53 -06:00

DTOS

About NTOS

This was taken as a base from Derek Taylers DTOS package While i like the idea of the post install script. Some of the defaults there are not what i want. I have since taken to customizing this and will update as needed.

NTOS Scrot

Installing NTOS

Installation instructions

To install DTOS, you need to clone this repository and run the dtos script.

git clone https://git.nave.house/nos
cd ntos/
./ntos

Potential bugs

Slow download times.

This script can take a long time to complete since it will install more than 300 packages. Also, make sure that the Linux distro that you are installing this on uses ParallelDownloads in /etc/pacman.conf for faster download times! For an example, to enable ParallelDownloads so it downloads up to five packages at a time:

ParallelDownloads = 5

Package conflicts that cause the script to fail

  • shell-color-scripts (from dtos-core-repo) conflicts with shell-color-scripts from the AUR.
  • dtos-opendoas (from dtos-core-repo) conflicts with opendoas from the Arch repos.

The solution is, before running the script, edit the pkglist.txt file and remove the packages above.

Doom Emacs doesn't launch.

After the installation is completed, Doom Emacs may not launch correctly the very first time. Killing the Emacs server (if running) and restarting it fixes this.

killall emacs
/usr/bin/emacs --daemon &

Updating NTOS

NTOS is updated in the standard way as all Arch-based Linux distros:

sudo pacman -Syu

This script is not a package in and of itself. This is just a collection of scripts to install some needed packages. This would run better as an ansible package but this format is fun and engaging.

Shebang plus comments

#
#  _   _ _____ _____ _____
# | \ | |_   _|  _  /  ___|
# |  \| | | | | | | \ `--.
# | . ` | | | | | | |`--. \
# | |\  | | | \ \_/ /\__/ /
# \_| \_/ \_/  \___/\____/
#
# NAME: NTOS
# DESC: An installation and deployment script for Naves Qtile Desktop
# WARNING: Run this script at your own risk.
# DEPENDENCIES: libnewt (probably already on the system)

Check that user is NOT root!

Don't run this script as root! This is done for safety reasons. This script makes a lot of changes to the $HOME of the $USER of this script. For obvious reasons, we want $USER to not be 'root' and $HOME not to be '/root'. Instead, run this script as a normal user. You will be asked to enter a sudo password at several points during the installation.

if [ "$(id -u)" = 0 ]; then
    echo "##################################################################"
    echo "This script MUST NOT be run as root user since it makes changes"
    echo "to the \$HOME directory of the \$USER executing this script."
    echo "The \$HOME directory of the root user is, of course, '/root'."
    echo "We don't want to mess around in there. So run this script as a"
    echo "normal user. You will be asked for a sudo password when necessary."
    echo "##################################################################"
    exit 1
fi

A function for errors

error() { \
    clear; printf "ERROR:\\n%s\\n" "$1" >&2; exit 1;
}

Whiptail Exports

These exports are the only way to specify colors with whiptail. See this thread for more info: https://askubuntu.com/questions/776831/whiptail-change-background-color-dynamically-from-magenta/781062 For more info on 'whiptail' see: https://en.wikibooks.org/wiki/Bash_Shell_Scripting/Whiptail

export NEWT_COLORS="
root=,blue
window=,black
shadow=,blue
border=blue,black
title=blue,black
textbox=blue,black
radiolist=black,black
label=black,blue
checkbox=black,blue
compactbutton=black,blue
button=black,red"

Sync the repos and install 'whiptail'

echo "##################################################################"
echo "## Syncing the repos and installing 'whiptail' if not installed ##"
echo "##################################################################"
sudo pacman --noconfirm --needed -Sy
sudo pacman --noconfirm --needed -Syu libnewt || error "Error syncing the repos."

Welcome message

welcome() { \
    whiptail --title "Installing NTOS!" --msgbox "This script will install the basic arch packages for some DE and clone my personal(private) repo's. You must have your key in git for this to work" 16 60
}

welcome || error "User choose to exit."

Warning the user about potential problems

speedwarning() { \
    whiptail --title "Installing NTOS!" --yesno "WARNING! The ParallelDownloads option is not enabled in /etc/pacman.conf. This may result in slower installation speeds. Are you sure you want to continue?" 16 60 || error "User choose to exit."
}

distrowarning() { \
    whiptail --title "Installing DTOS!" --msgbox "WARNING! While this script works on all Arch based distros, some distros choose to package certain things that we also package, which may result in errors when trying to install DTOS packages. If this happens, please look at the package list and remove conflicts manually." 16 60 || error "User choose to exit."
}

grep -qs "#ParallelDownloads" /etc/pacman.conf && speedwarning
grep -qs "ID=arch" /etc/os-release || distrowarning

Asking user to confirm choice to install NTOS.

lastchance() { \
    whiptail --title "Installing NTOS!" --msgbox "WARNING! The NTOS installation script is currently in public beta testing. There are almost certainly errors in it; therefore, it is strongly recommended that you not install this on production machines. It is recommended that you try this out in either a virtual machine or on a test machine." 16 60

    whiptail --title "Are You Sure You Want To Do This?" --yesno "Shall we begin installing NTOS?" 8 60 || { clear; exit 1; }
}

lastchance || error "User choose to exit."

Checking locale.conf

For some users, the LC_CTYPE variable is needed in the /etc/locale.conf for some programs (like dmenu) to work properly. The following checks if the LC_CTYPE has been set. If it has not been set, it will automatically be created using the same value as your LANG variable. Then, a 'sudo locale-gen' will be run to generate the new locale settings. These will take effect upon a reboot which should be done anyway once the DTOS installation has completed.

grep "LC_CTYPE" /etc/locale.conf && echo "Checking the LC_CYPE variable in /etc/locale.conf. Variable is already set." || grep "LANG=" /etc/locale.conf | sed 's/LANG=/LC_CTYPE=/g' | sudo tee -a /etc/locale.conf
sudo locale-gen

Adding DTOS repo to pacman.conf.

addrepo() { \
    echo "#########################################################"
    echo "## Adding the DTOS core repository to /etc/pacman.conf ##"
    echo "## this is needed for some dm-scripts and a few other  ##"
    echo "## things. This will likely get removed in future vers ##"
    echo "#########################################################"
    grep -qxF "[dtos-core-repo]" /etc/pacman.conf ||
        ( echo " "; echo "[dtos-core-repo]"; echo "SigLevel = Optional DatabaseOptional"; \
        echo "Server = https://gitlab.com/dtos/\$repo/-/raw/main/\$arch") | sudo tee -a /etc/pacman.conf
}

addrepo || error "Error adding DTOS repo to /etc/pacman.conf."

Installing paru

Let's go ahead and install the paru AUR helper because some of the software that the user could choose to install is only found the AUR.

install_paru() {
  # Create the /usr/external directory with sudo privileges
  sudo mkdir -p /usr/external
  sudo chown $(whoami):$(whoami) /usr/external

  # Navigate to the /usr/external directory
  cd /usr/external

  # Install base-devel
  sudo pacman -S --needed base-devel

  # Clone the paru repository
  git clone https://aur.archlinux.org/paru.git

  # Change the current directory to the paru directory
  cd paru

  # Build and install paru
  makepkg -srci
}
install_paru || error "Error paru"

Installing window manager(s)

choosewm() { \
    whiptail --title "CHOOSE YOUR WINDOW MANAGER(S)" --msgbox "Choose at least one window manager to install. The choices are: Xmonad, Awesome and Qtile. If unsure, Qtile is the recommended choice, or install all options and try out each of them." 16 60
}

installxmonad() { \
    whiptail --title "Window Managers - Xmonad" --yesno "Would you like to install Xmonad?" 8 60
}

installawesome() { \
    whiptail --title "Window Managers - Awesome" --yesno "Would you like to install Awesome?" 8 60
}

installbspwm() { \
    whiptail --title "Window Managers - Bspwm" --yesno "Would you like to install Bspwm?" 8 60
}

installdwm() { \
    whiptail --title "Window Managers - Dwm" --yesno "Would you like to install Dwm?" 8 60
}

installqtile() { \
    whiptail --title "Window Managers - Qtile" --yesno "Would you like to install Qtile?" 8 60
}

choosewm || error "User chose to exit"

installxmonad && sudo pacman -Sy xmonad xmonad-contrib xmobar polybar || echo "User chose not to install XMonad"

installawesome && sudo pacman -Sy awesome || echo "User chose not to install Awesome"

installqtile && paru --needed --ask 4 -Sy qtile qtile-extras python-psutil || echo "User chose not to install Qtile"

Choose your software

Three functions we use later

The following three functions are defined here for convenience. All three of these functions are used in each of the five window functions below, so we define them here one time (for convenience). Some of the options are broken and need to be hand fixed need to find a way to handle this better.

max() {
    echo -e "$1\n$2" | sort -n | tail -1
}

getbiggestword() {
    echo "$@" | sed "s/ /\n/g" | wc -L
}

replicate() {
    local n="$1"
    local x="$2"
    local str

    for _ in $(seq 1 "$n"); do
        str="$str$x"
    done
    echo "$str"
}

programchoices() {
    choices=()
    local maxlen; maxlen="$(getbiggestword "${!checkboxes[@]}")"
    linesize="$(max "$maxlen" 42)"
    local spacer; spacer="$(replicate "$((linesize - maxlen))" " ")"

    for key in "${!checkboxes[@]}"
    do
        # A portable way to check if a command exists in $PATH and is executable.
        # If it doesn't exist, we set the tick box to OFF.
        # If it exists, then we set the tick box to ON.
        if ! command -v "${checkboxes[$key]}" > /dev/null; then
            # $spacer length is defined in the individual window functions based
            # on the needed length to make the checkbox wide enough to fit window.
            choices+=("${key}" "${spacer}" "OFF")
        else
            choices+=("${key}" "${spacer}" "ON")
        fi
    done
}

selectedprograms() {
    result=$(
        # Creates the whiptail checklist. Also, we use a nifty
        # trick to swap stdout and stderr.
        whiptail --title "$title"                               \
                 --checklist "$text" 22 "$((linesize + 16))" 12 \
                 "${choices[@]}"                                \
                 3>&2 2>&1 1>&3
    )
}

exitorinstall() {
    exitstatus=$?
    # Check the exit status, if 0 we will install the selected
    # packages. A command which exits with zero (0) has succeeded.
    # A non-zero (1-255) exit status indicates failure.
    if [ $exitstatus = 0 ]; then
        # Take the results and remove the "'s and add new lines.
        # Otherwise, pacman is not going to like how we feed it.
        programs=$(echo $result | sed 's/" /\n/g' | sed 's/"//g' )
        echo $programs
        paru --needed --ask 4 -Sy "$programs" || \
        echo "Failed to install required packages."
    else
        echo "User selected Cancel."
    fi
}

The five individual window functions

These five functions are the whiptail checkbox windows.

browsers () {
    title="Web Browsers"
    text="Select one or more web browsers to install.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them."
    spacer=$(for i in $(seq 1 38); do echo -n " "; done)

    local -A checkboxes
    checkboxes["brave-bin"]="brave"
    checkboxes["chromium"]="chromium"
    checkboxes["firefox"]="firefox"
    checkboxes["google-chrome"]="google-chrome-stable"
    checkboxes["icecat-bin"]="icecat"
    checkboxes["librewolf-bin"]="librewolf"
    checkboxes["microsoft-edge-stable-bin"]="microsoft-edge-stable"
    checkboxes["opera"]="opera"
    checkboxes["qutebrowser"]="qutebrowser"
    checkboxes["ungoogled-chromium-bin"]="ungoogled-chromium"
    checkboxes["vivaldi"]="vivaldi"

    programchoices && selectedprograms && exitorinstall
}

otherinternet () {
    title="Other Internet Programs"
    text="Other Internet programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them."
    spacer=$(for i in $(seq 1 47); do echo -n " "; done)

    local -A checkboxes
    checkboxes["deluge"]="deluge"
    checkboxes["discord"]="discord"
    checkboxes["element-desktop"]="element-desktop"
    checkboxes["filezilla"]="filezilla"
    checkboxes["geary"]="geary"
    checkboxes["hexchat"]="hexchat"
    checkboxes["jitsi-meet-bin"]="jitsi-meet-desktop"
    checkboxes["mailspring"""]="mailspring"
    checkboxes["telegram-desktop"]="telegram"
    checkboxes["thunderbird"]="thunderbird"
    checkboxes["transmission-gtk"]="transmission-gtk"

    programchoices && selectedprograms && exitorinstall
}

multimedia() {
    title="Multimedia Programs"
    text="Multimedia programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them."
    spacer=$(for i in $(seq 1 53); do echo -n " "; done)

    local -A checkboxes
    checkboxes["blender"]="blender"
    checkboxes["deadbeef"]="deadbeef"
    checkboxes["gimp"]="gimp"
    checkboxes["inkscape"]="inkscape"
    checkboxes["kdenlive"]="kdenlive"
    checkboxes["krita"]="krita"
    checkboxes["mpv"]="mpv"
    checkboxes["obs-studio"]="obs"
    checkboxes["rhythmbox"]="rhythmbox"
    checkboxes["ristretto"]="ristretto"
    checkboxes["vlc"]="vlc"

    programchoices && selectedprograms && exitorinstall
}

office() {
    title="Office Programs"
    text="Office and productivity programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them."
    spacer=$(for i in $(seq 1 46); do echo -n " "; done)

    local -A checkboxes
    checkboxes["abiword"]="abiword"
    checkboxes["evince"]="evince"
    checkboxes["gnucash"]="gnucash"
    checkboxes["gnumeric"]="gnumeric"
    checkboxes["libreoffice-fresh"]="lowriter"
    checkboxes["libreoffice-still"]="lowriter"
    checkboxes["scribus"]="scribus"
    checkboxes["zathura"]="zathura"

    programchoices && selectedprograms && exitorinstall
}

games () {
    title="Games"
    text="Gaming programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them."
    spacer=$(for i in $(seq 1 51); do echo -n " "; done)

    local -A checkboxes
    checkboxes["0ad"]="0ad"
    checkboxes["gnuchess"]="gnuchess"
    checkboxes["lutris"]="lutris"
    checkboxes["neverball"]="neverball"
    checkboxes["openarena"]="openarena"
    checkboxes["steam"]="steam"
    checkboxes["supertuxkart"]="supertuxkart"
    checkboxes["sauerbraten"]="sauerbraten-client"
    checkboxes["teeworlds"]="teeworlds"
    checkboxes["veloren-bin"]="veloren"
    checkboxes["wesnoth"]="wesnoth"
    checkboxes["xonotic"]="xonotic-glx"

    programchoices && selectedprograms && exitorinstall
}

browsers
otherinternet
multimedia
office
games

Install the base packages from repositories

All packages listed are either in the standard Arch repos or in the DTOS repos. All of these will be installed using pacman. The only program that will not be installed through pacman is Doom Emacs, which will be installed later in the script.

NOTE: The 'ask 4' option is an undocumented option for pacman that can be found in pacman's source code (in pacman's alpm.h). Adding this flags means that all questions about removing packages that are conflicts will automatically be answered YES.

# Let's install each package listed in the pkglist.txt file.
sudo pacman --needed --ask 4 -Sy - < pkglist.txt || error "Failed to install a required package from pkglist.txt."

Copy configs over from /etc/dtos into $HOME

This is the part where we clone down the repo's. Since most of them are not public you need to have access to the repos. Maybe in the future they will be made public but unlikely.

echo "################################################################"
echo "## Cloning Mordent Minds Personal Repos. You are required to  ##"
echo "## have a key. You have been warned.                          ##"
echo "################################################################"
paru --noconfirm starship
mkdir -p $HOME/.config/{doom,qtile,alacritty}
mkdir -p $HOME/dotfiles
git clone ssh://git@git.nave.house:222/jnave/zsh-extras.git $HOME/dotfiles/zsh-extras
git clone ssh://git@git.nave.house:222/jnave/qtile-config.git $HOME/dotfiles/qtile-config
git clone ssh://git@git.nave.house:222/jnave/zsh-config.git $HOME/dotfiles/zsh-config
git clone ssh://git@git.nave.house:222/jnave/doom-emacs.git $HOME/.config/doom
git clone ssh://git@git.nave.house:222/jnave/alacritty-dotfiles.git $HOME/dotfiles/alacritty-dotfiles
git clone ssh://git@git.nave.house:222/jnave/starship-dotfiles.git $HOME/dotfiles/starship-dotfiles
# Change all scripts in .local/bin to be executable.
find $HOME/.local/bin -type f -print0 | xargs -0 chmod 775

Install Doom Emacs

echo "#########################################################"
echo "## Installing Doom Emacs. This may take a few minutes. ##"
echo "#########################################################"
[ -d ~/.emacs.d ] && mv ~/.emacs.d ~/.emacs.d.bak.$(date +"%Y%m%d_%H%M%S")
[ -f ~/.emacs ] && mv ~/.emacs ~/.emacs.bak.$(date +"%Y%m%d_%H%M%S")
git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs
~/.config/emacs/bin/doom --force install
~/.config/emacs/bin/doom sync

Copy pacman hooks for xmonad if installed

The following pacman hooks force xmonad to recompile every time there are updates to xmonad or the haskell libraries.

[ ! -d /etc/pacman.d/hooks ] && sudo mkdir /etc/pacman.d/hooks
[ -f /usr/bin/xmonad ] && sudo cp /etc/dtos/.config/xmonad/pacman-hooks/recompile-xmonad.hook /etc/pacman.d/hooks/
[ -f /usr/bin/xmonad ] && sudo cp /etc/dtos/.config/xmonad/pacman-hooks/recompile-xmonadh.hook /etc/pacman.d/hooks/

Compiling xmonad

NOTE: May not be needed if moving the pacman hooks works as expected.

xmonad_recompile() { \
    echo "########################"
    echo "## Recompiling XMonad ##"
    echo "########################"
    xmonad --recompile
}

[ -f /usr/bin/xmonad ] && xmonad_recompile || echo "Recompiling Xmonad failed!"

Compiling the xmonadctl script

xmonadctl_compile() { \
    echo "####################################"
    echo "## Compiling the xmonadctl script ##"
    echo "####################################"
    ghc -dynamic "$HOME"/.config/xmonad/xmonadctl.hs
}

xmonadctl_compile || echo "Compiling the xmonadctl script failed!"

Set default USER shell

PS3='Set default user shell (enter number): '
shells=("fish" "bash" "zsh" "quit")
select choice in "${shells[@]}"; do
    case $choice in
         fish | bash | zsh)
            sudo chsh $USER -s "/bin/$choice" && \
            echo -e "$choice has been set as your default USER shell. \
                    \nLogging out is required for this take effect."
            break
            ;;
         quit)
            echo "User quit without changing shell."
            break
            ;;
         *)
            echo "invalid option $REPLY"
            ;;
    esac
done

Enable SDDM for login manager

Disable the currently enabled display manager and enable SDDM instead.

# Disable the current login manager
sudo systemctl disable $(grep '/usr/s\?bin' /etc/systemd/system/display-manager.service | awk -F / '{print $NF}') || echo "Cannot disable current display manager."
# Enable sddm as login manager
sudo systemctl enable sddm
echo "###################################"
echo "## Enable sddm as login manager. ##"
echo "###################################"

## Make multicolor-sddm-theme the default sddm theme ##
# This is the sddm system configuration file.
[ -f "/usr/lib/sddm/sddm.conf.d/default.conf" ] && \
    sudo cp /usr/lib/sddm/sddm.conf.d/default.conf /usr/lib/sddm/sddm.conf.d/default.conf.backup && \
    sudo sed -i 's/^Current=*.*/Current=multicolor-sddm-theme/g' /usr/lib/sddm/sddm.conf.d/default.conf

# This is the sddm local configuration file.
[ -f "/etc/sddm.conf" ] && \
    sudo cp /etc/sddm.conf /etc/sddm.conf.backup && \
    sudo sed -i 's/^Current=*.*/Current=multicolor-sddm-theme/g' /etc/sddm.conf

# Create a local configuration file if it doesn't exist.
# Standard Arch Linux does not create this file by default.
[ ! -f "/etc/sddm.conf" ] && \
    sudo cp /usr/lib/sddm/sddm.conf.d/default.conf /etc/sddm.conf || echo "Default sddm system config file is not found."

# ArcoLinux B Awesome uses this config location.
[ -f "/etc/sddm.conf.d/kde_settings.conf" ] && \
    sudo cp /etc/sddm.conf.d/kde_settings.conf /etc/sddm.conf.d/kde_settings.backup && \
    sudo sed -i 's/^Current=*.*/Current=multicolor-sddm-theme/g' /etc/sddm.conf.d/kde_settings.conf

Message stating that the installation is complete!

echo "##############################"
echo "## DTOS has been installed! ##"
echo "##############################"

while true; do
    read -p "Do you want to reboot to get your dtos? [Y/n] " yn
    case $yn in
        [Yy]* ) reboot;;
        [Nn]* ) break;;
        "" ) reboot;;
        * ) echo "Please answer yes or no.";;
    esac
done
Description
No description provided
Readme 69 KiB
Languages
Shell 100%