### Setup Dropbox Headless Client Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs and configures the Dropbox command-line client for headless operation. This includes installing dependencies, downloading the CLI tool, updating Dropbox, starting the daemon, and enabling it to restart on boot. ```shell #!/bin/zsh # Install required dependencies sudo apt update && sudo apt install -y \ libglapi-mesa \ libxdamage1 \ libxfixes3 \ libxcb-glx0 \ libxcb-dri2-0 \ libxcb-dri3-0 \ libxcb-present0 \ libxcb-sync1 \ libxshmfence1 \ libxxf86vm1 \ python3-gpg # Install CLI tool sudo curl -L "https://www.dropbox.com/download?dl=packages/dropbox.py" -o /usr/bin/dropbox sudo chmod +x /usr/bin/dropbox # Download and install Dropbox headless dropbox update # Start daemon dropbox start # Makes daemon restart on boot dropbox autostart y ``` -------------------------------- ### Install MariaDB (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs the MariaDB server and runs the secure installation script. This sets up the database server for the system. ```shell #!/bin/bash sudo apt update && sudo apt install -y mariadb-server sudo mysql_secure_installation ``` -------------------------------- ### Install Go Source: https://github.com/alex-d/dotfiles/blob/main/README.md Downloads and installs a specific version of Go (1.16.4) to /usr/local. It removes any previous installation before extracting the new one. Requires root privileges. ```shell #!/bin/zsh goVersion=1.16.4 curl -L "https://golang.org/dl/go${goVersion}.linux-amd64.tar.gz" > /tmp/go${goVersion}.linux-amd64.tar.gz sudo rm -rf /usr/local/go sudo tar -C /usr/local -xzf /tmp/go${goVersion}.linux-amd64.tar.gz rm /tmp/go${goVersion}.linux-amd64.tar.gz ``` -------------------------------- ### Install Git Filter Repo Source: https://github.com/alex-d/dotfiles/blob/main/README.md Clones the git-filter-repo repository, builds the documentation, and installs the binary and man pages into the local Git installation paths. Requires make and git to be installed on the system. ```shell #!/bin/zsh git clone git@github.com:newren/git-filter-repo.git /tmp/git-filter-repo cd /tmp/git-filter-repo make snag_docs sudo cp -a git-filter-repo $(git --exec-path) sudo cp -a Documentation/man1/git-filter-repo.1 $(git --man-path)/man1 sudo cp -a Documentation/html/git-filter-repo.html $(git --html-path) cd - rm -rf /tmp/git-filter-repo ``` -------------------------------- ### Setup Docker with APT Source: https://github.com/alex-d/dotfiles/blob/main/README.md Installs Docker CE, CLI, and containerd.io on Ubuntu-based systems by adding the official Docker repository. It also adds the current user to the 'docker' group for easier access. Requires root privileges for installation. ```shell #!/bin/zsh # Add Docker to sources.list curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Install tools sudo apt update && sudo apt install -y \ docker-ce docker-ce-cli containerd.io # Add user to docker group sudo usermod -aG docker $USER ``` -------------------------------- ### Setup Zsh Shell (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs zsh, clones dotfiles, installs Antibody for plugin management, configures zsh plugins and aliases, and sets zsh as the default shell. ```shell #!/bin/bash # Clone the dotfiles repository mkdir -p ~/dotfiles git clone git@github.com:Alex-D/dotfiles.git ~/dotfiles # Install Antibody and generate .zsh_plugins.zsh curl -sfL git.io/antibody | sudo sh -s - -b /usr/local/bin antibody bundle < ~/dotfiles/zsh_plugins > ~/.zsh_plugins.zsh # Link custom dotfiles ln -sf ~/dotfiles/.aliases.zsh ~/.aliases.zsh ln -sf ~/dotfiles/.p10k.zsh ~/.p10k.zsh ln -sf ~/dotfiles/.zshrc ~/.zshrc # Change default shell to zsh chsh -s $(which zsh) ``` -------------------------------- ### Install Node.js with Volta Source: https://github.com/alex-d/dotfiles/blob/main/README.md Installs Volta, a JavaScript tool manager, and then uses it to install the latest versions of Node.js, npm, and yarn. This script assumes VOLTA_HOME is set or creates it. ```shell #!/bin/zsh # Install Volta mkdir -p $VOLTA_HOME curl https://get.volta.sh | bash -s -- --skip-setup # Install node and package managers volta install node npm yarn ``` -------------------------------- ### Install kubectl on Linux Source: https://github.com/alex-d/dotfiles/blob/main/README.md Installs the Kubernetes command-line tool using the official Google Cloud APT repository. It adds the GPG key, configures the package source, and performs an update before installation. ```shell #!/bin/zsh sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list sudo apt-get update sudo apt-get install -y kubectl ``` -------------------------------- ### Configure Zsh and Git GPG Signing in GitBash Source: https://context7.com/alex-d/dotfiles/llms.txt Installs Zsh, links dotfiles, and configures Git to use GPG signing and SSH keys shared with WSL 2. ```bash pacman -S zsh mkdir -p ~/dev/dotfiles git clone git@github.com:Alex-D/dotfiles.git ~/dev/dotfiles ln -sf ~/dev/dotfiles/.aliases.zsh ~/.aliases.zsh ln -sf ~/dev/dotfiles/.p10k.zsh ~/.p10k.zsh ln -sf ~/dev/dotfiles/.zshrc ~/.zshrc ln -sf ~/dev/dotfiles/git-bash/.zsh_plugins.zsh ~/.zsh_plugins.zsh git config --global user.email "contact@alex-d.fr" git config --global user.name "Alex-D" git config --global user.signingkey "8FA78E6580B1222A" git config --global commit.gpgsign true git config --global gpg.program "$HOME/dev/dotfiles/git-bash/.gpg-pinentry-loopback" git config --global core.sshCommand "ssh -i //wsl$/Ubuntu/home/ademode/.ssh/id_rsa" wsl.exe gpg -a --export-secret-keys | gpg --import --pinentry-mode loopback ``` -------------------------------- ### Install IntelliJ IDEA Source: https://github.com/alex-d/dotfiles/blob/main/README.md Installs IntelliJ IDEA Community Edition by downloading the latest Linux version and extracting it to /opt/idea. It also installs necessary GUI dependencies and sets ownership for user updates. Requires root privileges for installation. ```shell #!/bin/zsh # Install IDEA dependencies sudo apt update && sudo apt install -y \ fontconfig \ libxss1 \ libnss3 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libgbm1 \ libpangocairo-1.0-0 \ libcups2 \ libxkbcommon0 # Create install folder sudo mkdir /opt/idea # Allow your user to run IDEA updates from GUI sudo chown $UID:$UID /opt/idea # Download IntelliJ IDEA curl -L "https://download.jetbrains.com/product?code=IIU&latest&distribution=linux" | tar vxz -C /opt/idea --strip 1 ``` -------------------------------- ### Install Composer (Zsh) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs Composer, the dependency manager for PHP. It downloads the installer, verifies its checksum, and moves the executable to /usr/bin/composer. ```zsh #!/bin/zsh EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ACTUAL_CHECKSUM="$(php -r \"echo hash_file('sha384', 'composer-setup.php');\")" if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] then >&2 echo 'ERROR: Invalid installer checksum' else php composer-setup.php --quiet sudo mv composer.phar /usr/bin/composer fi rm composer-setup.php ``` -------------------------------- ### Install Nginx (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs the Nginx web server on Debian 10 using apt. This is a prerequisite for serving websites. ```shell #!/bin/bash sudo apt update && sudo apt install -y nginx ``` -------------------------------- ### Setup New User (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Creates a new user, assigns sudo privileges, and optionally removes the default user. Requires manual logout/login after execution. ```shell #!/bin/bash username="ademode" # Create a new user (use a password generator) sudo adduser "${username}" sudo usermod -aG sudo "${username}" # Logout and login with this new user # If needed, delete default provided user (if not root) sudo deluser --remove-home debian ``` -------------------------------- ### Install and Setup UFW Firewall Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs the Uncomplicated Firewall (UFW) and configures it to allow incoming traffic for SSH, HTTP, HTTPS, and SMTP. UFW is a user-friendly interface for managing iptables. ```shell sudo apt update && sudo apt install -y \ ufw ``` ```shell #!/bin/zsh sudo ufw allow ssh sudo ufw allow http sudo ufw allow https sudo ufw allow smtp ``` -------------------------------- ### Setup Git and SSH Key (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Generates an RSA SSH key pair, starts the ssh-agent, adds the key, and displays the public key for easy copying. Used for secure Git operations. ```shell #!/bin/bash email="contact@alex-d.fr" # Generate a new SSH key ssh-keygen -t rsa -b 4096 -C "${email}" # Start ssh-agent and add the key to it eval $(ssh-agent -s) ssh-add ~/.ssh/id_rsa # Display the public key ready to be copy pasted to GitHub cat ~/.ssh/id_rsa.pub ``` -------------------------------- ### Install GitHub CLI Source: https://github.com/alex-d/dotfiles/blob/main/README.md Adds the official GitHub CLI repository to the system sources and installs the 'gh' tool for managing GitHub interactions from the terminal. ```bash #!/bin/zsh curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null sudo apt update sudo apt install gh ``` -------------------------------- ### Setup Fail2ban (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs Fail2ban, a service that protects your server by monitoring log files and banning IPs that show malicious signs. ```shell sudo apt update && sudo apt install -y fail2ban ``` -------------------------------- ### Install PHP-FPM and Extensions (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs PHP-FPM version 8.0 and common extensions from the sury repository. Requires adding the repository's GPG key and source list. ```shell #!/bin/bash # Download and add the sury repository gpg key curl https://packages.sury.org/php/apt.gpg -o /tmp/packages.sury.org.gpg sudo apt-key add /tmp/packages.sury.org.gpg # Add sury repository echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list # Install PHP php_version="8.0" sudo apt update && sudo apt install -y unzip php${php_version} php${php_version}-cli php${php_version}-common php${php_version}-fpm php${php_version}-pdo php${php_version}-pdo-mysql php${php_version}-gd php${php_version}-intl php${php_version}-dom php${php_version}-xml ``` -------------------------------- ### Setup Dropbox Uploader CLI Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Downloads and installs the Dropbox Uploader script, making it executable. This tool allows command-line interaction with Dropbox for uploading and downloading files. The first run requires user authorization. ```shell #!/bin/zsh # Download and install Dropbox Uploader sudo curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o /usr/bin/dropbox_uploader sudo chmod +x /usr/bin/dropbox_uploader # First run: follow instructions dropbox_uploader ``` -------------------------------- ### Install System Dependencies Source: https://github.com/alex-d/dotfiles/blob/main/README.md Updates the package manager and installs common development utilities including git, zsh, and build tools on Ubuntu/WSL. ```bash #!/bin/bash sudo apt update && sudo apt install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common \ git \ make \ tig \ tree \ zip unzip \ zsh ``` -------------------------------- ### Install Common Dependencies (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Installs essential packages for a Debian 10 server using apt. Includes packages for package management, curl, wget, git, and zsh. ```shell #!/bin/bash sudo apt update && sudo apt install -y \ apt-transport-https \ ca-certificates \ curl \ wget \ gnupg2 \ software-properties-common \ man \ perl \ git \ tig \ tree \ zsh ``` -------------------------------- ### Setup VcXsrv for IntelliJ IDEA GUI Source: https://github.com/alex-d/dotfiles/blob/main/README.md Copies a pre-configured VcXsrv XLaunch settings file to the Windows startup folder for automatic launching. This enables running GUI applications from WSL 2 and displaying them on Windows. It dynamically determines the Windows user profile. ```shell windowsUserProfile=/mnt/c/Users/$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r') # Run VcXsrv at startup cp ~/dev/dotfiles/config.xlaunch "${windowsUserProfile}/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup" ``` -------------------------------- ### Install Docker Compose Source: https://github.com/alex-d/dotfiles/blob/main/README.md Downloads and installs the latest version of Docker Compose to /usr/local/bin. It fetches the correct binary for the current operating system and architecture. Requires root privileges. ```shell #!/bin/zsh sudo curl -sL -o /usr/local/bin/docker-compose $(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep "browser_download_url.*$(uname -s | awk '{print tolower($0)}')-$(uname -m)" | grep -v sha | cut -d: -f2,3 | tr -d \") sudo chmod +x /usr/local/bin/docker-compose ``` -------------------------------- ### Install AWS CLI v2 on Linux Source: https://github.com/alex-d/dotfiles/blob/main/README.md Downloads, unzips, and installs the AWS Command Line Interface version 2. The script cleans up temporary installation files after the process is complete. ```shell #!/bin/zsh cd /tmp/aws-cli curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install cd - rm -rf /tmp/aws-cli ``` -------------------------------- ### Setup zsh and Dotfiles Source: https://github.com/alex-d/dotfiles/blob/main/README.md Clones the dotfiles repository, installs the Antibody plugin manager, symlinks configuration files, and sets zsh as the default shell. ```bash #!/bin/bash mkdir -p ~/dev/dotfiles git clone git@github.com:Alex-D/dotfiles.git ~/dev/dotfiles curl -sfL git.io/antibody | sudo sh -s - -b /usr/local/bin antibody bundle < ~/dev/dotfiles/zsh_plugins > ~/.zsh_plugins.zsh ln -sf ~/dev/dotfiles/.aliases.zsh ~/.aliases.zsh ln -sf ~/dev/dotfiles/.p10k.zsh ~/.p10k.zsh ln -sf ~/dev/dotfiles/.zshrc ~/.zshrc ln -sf ~/dev/dotfiles/.gitignore ~/.gitignore mkdir ~/.screen && chmod 700 ~/.screen chsh -s $(which zsh) ``` -------------------------------- ### Configure Git and SSH Source: https://github.com/alex-d/dotfiles/blob/main/README.md Sets global Git user configuration, enables GPG commit signing, generates a new RSA SSH key, and starts the ssh-agent to manage authentication. ```bash #!/bin/bash email="contact@alex-d.fr" username="Alex-D" gpgkeyid="8FA78E6580B1222A" git config --global user.email "${email}" git config --global user.name "${username}" git config --global user.signingkey "${gpgkeyid}" git config --global commit.gpgsign true git config --global core.pager /usr/bin/less git config --global core.excludesfile ~/.gitignore ssh-keygen -t rsa -b 4096 -C "${email}" eval $(ssh-agent -s) ssh-add ~/.ssh/id_rsa cat ~/.ssh/id_rsa.pub ``` -------------------------------- ### Manage Zsh Plugins Source: https://context7.com/alex-d/dotfiles/llms.txt A configuration file for the Antibody plugin manager. It bundles the Powerlevel10k theme, Oh-My-Zsh libraries, and productivity tools like syntax highlighting and autosuggestions. ```bash # ~/zsh_plugins - Antibody plugin bundle file # Powerlevel10k Prompt Theme romkatv/powerlevel10k # Core Plugins rupa/z # Directory jumping robbyrussell/oh-my-zsh path:lib/git.zsh # Git library robbyrussell/oh-my-zsh path:plugins/git # Git aliases and functions robbyrussell/oh-my-zsh path:plugins/tig # Tig integration robbyrussell/oh-my-zsh path:plugins/ssh-agent # SSH agent management robbyrussell/oh-my-zsh path:plugins/gpg-agent # GPG agent management robbyrussell/oh-my-zsh path:plugins/colored-man-pages # Colored man pages # Syntax and Autosuggestions zdharma-continuum/fast-syntax-highlighting # Syntax highlighting zsh-users/zsh-autosuggestions # Fish-like autosuggestions ``` -------------------------------- ### Schedule Folder Backup with Dropbox Uploader Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Sets up a cron job to automatically back up specified folders to Dropbox using the previously installed Dropbox Uploader script. The backup runs daily at 3 AM. ```shell #!/bin/zsh foldersToBackup="/var/www /etc/nginx/sites-available" newCron="0 3 * * * $HOME/dev/dotfiles/server/backup.sh $foldersToBackup" (crontab -l ; echo "$newCron") | crontab - ``` -------------------------------- ### Setup MySQL Database Backup Script Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Configures a script for backing up MySQL databases to Dropbox. It involves copying a configuration file for database credentials and setting up a cron job to run the backup script daily at 3 AM. ```shell #!/bin/zsh mkdir -p ~/.config/backup cp ~/dev/dotfiles/server/config/mysql ~/.config/backup/mysql ``` ```shell #!/bin/zsh databaseName="" newCron="0 3 * * * $HOME/dev/dotfiles/server/mysql_backup.sh $databaseName" (crontab -l ; echo "$newCron") | crontab - ``` -------------------------------- ### Automated MySQL Database Backup to Dropbox Source: https://context7.com/alex-d/dotfiles/llms.txt Dumps a MySQL database, compresses it, and uploads the result to Dropbox. Requires a configuration file containing DB_USER and DB_PWD. ```bash #!/bin/sh set -e DB_NAME=$1 CONFIG_PATH="$HOME/.config/backup/mysql" . "$CONFIG_PATH" TMP_DIR="/tmp" DUMP_PATH="$TMP_DIR/$DB_NAME.sql.gz" DROPBOX_UPLOADER_CONFIG_PATH="$HOME/.dropbox_uploader" MYSQL_PWD="$DB_PWD" mysqldump -u"$DB_USER" "$DB_NAME" | gzip > "$DUMP_PATH" dropbox_uploader -f "$DROPBOX_UPLOADER_CONFIG_PATH" upload "$DUMP_PATH" / rm -f "$DUMP_PATH" ``` -------------------------------- ### Install and Configure Zsh Source: https://github.com/alex-d/dotfiles/blob/main/git-bash/README.md Installs Zsh via pacman, clones dotfiles from a repository, and creates symbolic links for shell configuration files. It also sets up GPG agent and Git autocompletion scripts. ```shell #!/bin/bash pacman -S zsh # Launch zsh zsh # Clone the dotfiles repository mkdir -p ~/dev/dotfiles git clone git@github.com:Alex-D/dotfiles.git ~/dev/dotfiles # Link custom dotfiles ln -sf ~/dev/dotfiles/.aliases.zsh ~/.aliases.zsh ln -sf ~/dev/dotfiles/.p10k.zsh ~/.p10k.zsh ln -sf ~/dev/dotfiles/.zshrc ~/.zshrc ln -sf ~/dev/dotfiles/.gitignore ~/.gitignore ln -sf ~/dev/dotfiles/git-bash/.zsh_plugins.zsh ~/.zsh_plugins.zsh # GPG Agent mkdir ~/.gnupg ln -sf ~/dev/dotfiles/git-bash/gpg-agent.conf ~/.gnupg/gpg-agent.conf gpg-connect-agent reloadagent /bye # Git autocompletion mkdir -p ~/.zsh cd ~/.zsh curl -o git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash curl -o _git https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh ``` -------------------------------- ### Configure Zsh Environment Source: https://context7.com/alex-d/dotfiles/llms.txt The core .zshrc configuration file initializes the shell environment. It includes WSL 2 detection for GUI display, path exports for Go and Volta, and history management settings. ```bash # ~/.zshrc - Core zsh configuration #!/bin/zsh # Do not want background jobs to be at a lower priority unsetopt BG_NICE # WSL specific things - auto-detect and configure display if grep --quiet microsoft /proc/version 2>/dev/null; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')':0.0' export LIBGL_ALWAYS_INDIRECT=1 fi # Load custom aliases [ -f ~/.aliases.zsh ] && source ~/.aliases.zsh # Load zsh plugins (Generated via Antibody) ZSH_AUTOSUGGEST_STRATEGY=(history completion) [ -f ~/.zsh_plugins.zsh ] && source ~/.zsh_plugins.zsh # Preferred editor export EDITOR='vim' # Go environment if [[ -d /usr/local/go/bin ]]; then export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:$(go env GOPATH)/bin fi # Volta (node, npm) environment export VOLTA_HOME=$HOME/.volta export PATH=$VOLTA_HOME/bin:$PATH # History configuration HISTSIZE=5000 HISTFILE=~/.zsh_history SAVEHIST=5000 setopt extended_history setopt hist_expire_dups_first setopt hist_ignore_dups setopt hist_ignore_space setopt share_history ``` -------------------------------- ### Automated Server File Backup to Dropbox Source: https://context7.com/alex-d/dotfiles/llms.txt Compresses specified directories into a tarball, excluding version control and cache files, and uploads it to Dropbox using the dropbox_uploader utility. ```bash #!/bin/sh set -e TMP_DIR="/tmp" BACKUP_FILE="$TMP_DIR/$(hostname)-backup.tar.gz" DROPBOX_UPLOADER_CONFIG_PATH="$HOME/.dropbox_uploader" tar \ --exclude-vcs \ --exclude-backups \ --exclude "*app/cache*" \ --exclude "*var/cache*" \ --exclude "*vendor*" \ -czf \ "$BACKUP_FILE" \ "$@" dropbox_uploader -f "$DROPBOX_UPLOADER_CONFIG_PATH" upload "$BACKUP_FILE" / rm -f "$BACKUP_FILE" ``` -------------------------------- ### Change Hostname (Bash) Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Sets the system's hostname and updates the /etc/hosts file. Useful for identifying the server on the network. ```shell #!/bin/bash hostname="alexandredemode.fr" sudo hostnamectl set-hostname "${hostname}" echo "127.0.0.1 ${hostname}" | sudo tee -a /etc/hosts # Note: if the hostname doesn't have a global internet DNS entry, # set 127.0.1.1 instead ``` -------------------------------- ### Setup WSL Bridge Script Source: https://github.com/alex-d/dotfiles/blob/main/README.md Copies the `wsl2-bridge.ps1` PowerShell script to the Windows user's home directory. This script is used to create port proxies for WSL 2 network access. It dynamically determines the Windows user profile. ```shell #!/bin/zsh windowsUserProfile=/mnt/c/Users/$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r') # Get the hacky network bridge script cp ~/dev/dotfiles/wsl2-bridge.ps1 ${windowsUserProfile}/wsl2-bridge.ps1 ``` -------------------------------- ### Define Shell Aliases Source: https://context7.com/alex-d/dotfiles/llms.txt Custom aliases for directory navigation, file listing, and Docker Compose integration. It also includes conditional logic to define WSL-specific commands only when running inside the WSL environment. ```bash # ~/.aliases.zsh - Custom shell aliases #!/bin/zsh # Quick directory navigation alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." # Enhanced file listing with colors alias ls='ls --color=auto' alias lsa='ls -lah' alias l='ls -lah' alias ll='ls -lh' alias la='ls -lAh' # Grep with color and VCS exclusion alias grep="grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}" # Docker Compose shortcuts for Symfony development alias sf="docker-compose exec php bin/console" alias dc="docker-compose exec php composer" # WSL-specific aliases (only loaded in WSL environment) if grep --quiet microsoft /proc/version 2>/dev/null; then alias idea="(pkill -f 'java.*idea' || true) && screen -d -m /opt/idea/bin/idea.sh" alias wslb="PowerShell.exe 'Start-Process PowerShell -Verb RunAs \"PowerShell -File $env:USERPROFILE\\wsl2-bridge.ps1\"'" alias dcs="sudo /etc/init.d/docker start" fi ``` -------------------------------- ### Enable IPv6 on OVH VPS Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md Configures static IPv6 addressing and routing on an OVH VPS by creating a new network interfaces configuration file. This script requires the user to provide their specific IPv6 address and gateway. ```shell #!/bin/zsh YOUR_IPV6="xxxx:xxxx:xxxx:..." IPV6_GATEWAY="xxxx:xxxx:xxxx:..." sudo tee /etc/network/interfaces.d/51-cloud-init-ipv6.cfg > /dev/null </dev/null | tr -d '\r') ``` -------------------------------- ### Configure WSL RAM settings Source: https://github.com/alex-d/dotfiles/blob/main/README.md Copies a custom .wslconfig file to the Windows user profile directory to manage memory consumption. This script assumes the existence of a source configuration file in the local dotfiles repository. ```shell cp ~/dev/dotfiles/.wslconfig ${windowsUserProfile}/.wslconfig ``` -------------------------------- ### Set PowerShell Execution Policy Source: https://github.com/alex-d/dotfiles/blob/main/README.md Sets the PowerShell execution policy to 'RemoteSigned' and then runs the `wsl2-bridge.ps1` script. This is necessary to allow the bridge script to execute. Must be run in an elevated PowerShell prompt. ```powershell # In PowerShell as Administrator Set-ExecutionPolicy -ExecutionPolicy RemoteSigned PowerShell -File $env:USERPROFILE\wsl2-bridge.ps1 ``` -------------------------------- ### Run WSL Bridge Alias Source: https://github.com/alex-d/dotfiles/blob/main/README.md Executes the `wslb` alias, which is a custom command to run the `wsl2-bridge.ps1` script. This is used to resolve port forwarding issues between WSL 2 and Windows. This assumes the alias is defined in `.aliases.zsh`. ```shell #!/bin/zsh wslb ``` -------------------------------- ### Configure Fail2ban Jail Settings Source: https://github.com/alex-d/dotfiles/blob/main/server/README.md This configuration snippet enables various jails in Fail2ban, including SSH, SSHD-DDOS, recidive, and Nginx-related protections. It helps in preventing brute-force attacks and malicious bot activity by monitoring logs and banning suspicious IPs. ```ini [sshd] enabled = true [sshd-ddos] enabled = true [recidive] enabled = true [nginx-badbots] enabled = true [nginx-noproxy] enabled = true [nginx-nohome] enabled = true [nginx-http-auth] enabled = true ``` -------------------------------- ### Configure Windows Terminal Settings Source: https://github.com/alex-d/dotfiles/blob/main/README.md Copies a custom Windows Terminal settings JSON file to the default location, overwriting existing settings. This allows for pre-configured profiles, color schemes, and keybindings. It dynamically determines the Windows user profile. ```shell #!/bin/zsh windowsUserProfile=/mnt/c/Users/$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | tr -d '\r') # Copy Windows Terminal settings cp ~/dev/dotfiles/terminal-settings.json ${windowsUserProfile}/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState/settings.json ``` -------------------------------- ### Import GPG Keys from WSL2 Source: https://github.com/alex-d/dotfiles/blob/main/git-bash/README.md Exports secret GPG keys from a WSL2 instance and imports them into the current GitBash environment using a loopback pinentry mode. ```shell wsl.exe gpg -a --export-secret-keys | gpg --import --pinentry-mode loopback ``` -------------------------------- ### Configure Git Global Settings Source: https://github.com/alex-d/dotfiles/blob/main/git-bash/README.md Sets up global Git identity, GPG signing, and SSH configuration. It assumes the presence of specific GPG keys and SSH keys located within the WSL2 filesystem. ```shell #!/bin/bash # Set username and email for next commands email="contact@alex-d.fr" username="Alex-D" gpgkeyid="8FA78E6580B1222A" # Configure Git git config --global user.email "${email}" git config --global user.name "${username}" git config --global user.signingkey "${gpgkeyid}" git config --global commit.gpgsign true git config --global gpg.program "$HOME/dev/dotfiles/git-bash/.gpg-pinentry-loopback" git config --global core.pager /usr/bin/less git config --global core.excludesfile ~/.gitignore # Use ssh key from WSL2 git config --global core.sshCommand "ssh -i //wsl$/Ubuntu/home/ademode/.ssh/id_rsa" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.