#!/usr/bin/bash function create_dir () { printf "Create Directory \n" mkdir "$HOME"/.local/bin mkdir "$HOME"/Temp mkdir "$HOME"/Dev mkdir "$HOME"/Container printf "Success\n" } function install_zsh () { printf "Install zsh \n" if [ "$SHELL" != "/usr/bin/zsh" ]; then sudo pacman -Sy sudo pacman -S zsh --noconfirm chsh -s /usr/bin/zsh fi curl --proto '=https' -fLsS https://rossmacarthur.github.io/install/crate.sh | bash -s -- --repo rossmacarthur/sheldon --to ~/.local/bin export PATH="$PATH:$HOME/.local/bin" sheldon init --shell zsh echo 'export PATH="$PATH:$HOME/.local/bin"' | tee -a "$HOME/.zshrc" echo 'HISTFILE=$HOME/.zsh_history' | tee -a "$HOME/.zshrc" echo 'HISTSIZE=10000' | tee -a "$HOME/.zshrc" echo 'SAVEHIST=10000' | tee -a "$HOME/.zshrc" echo 'eval "$(sheldon source)"' | tee -a "$HOME/.zshrc" sheldon add zsh-completions --github zsh-users/zsh-completions sheldon add zsh-autocomplete --github marlonrichert/zsh-autocomplete --tag 23.07.13 sheldon add zsh-autosuggestions --github zsh-users/zsh-autosuggestions --use '{{ name }}.zsh' sheldon add zsh-syntax-highlighting --github zsh-users/zsh-syntax-highlighting sheldon add powerlevel10k --github romkatv/powerlevel10k } function setup_swapfile () { printf "Swapfile setup\n" printf "Please enter swapfile capacity (example : ~ M)\n" read swapcap if [ "$1" == "btrfs" ]; then sudo truncate -s 0 /swap/swapfile sudo chattr +C /swap/swapfile sudo fallocate -l "$swapcap"M /swap/swapfile sudo chmod 600 /swap/swapfile sudo mkswap /swap/swapfile sudo swapon /swap/swapfile echo "#swapfile_autogenerated" | sudo tee -a /etc/fstab echo "/swap/swapfile none swap defaults 0 0" | sudo tee -a /etc/fstab else sudo dd if=/dev/zero of=/swapfile bs=1M count="$swapcap" status=progress sudo chmod 600 /swapfile sudo mkswap -U clear /swapfile sudo swapon /swapfile sudo mkdir /etc/backup sudo cp /etc/fstab /etc/backup/fstab echo "#swapfile_autogenerated" | sudo tee -a /etc/fstab echo "/swapfile none swap defaults 0 0" | sudo tee -a /etc/fstab fi printf "swapfile setup is complete.\n" } function setup_time () { printf "Timezone setup\n" sudo timedatectl set-timezone Asia/Tokyo sudo timedatectl set-ntp true } function install_yay () { printf "AUR setup (yay)\n" cd "$HOME"/Temp sudo pacman -Sy sudo pacman -S --noconfirm git git clone https://aur.archlinux.org/yay.git cd yay makepkg -si --noconfirm cd "$HOME" } function install_fonts () { printf "Install CJK Fonts\n" sudo pacman -S --noconfirm noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra } function install_podman () { sudo pacman -S --noconfirm podman podman-compose podman-docker aardvark-dns echo 'export DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock"' | sudo tee -a /etc/environment mkdir ~/.config/containers echo "unqualified-search-registries = [\"docker.io\"]" >> ~/.config/containers/registries.conf systemctl --user enable podman.socket sudo loginctl enable-linger $UID } printf "Do you want to the initial setup? (yes or no)\n" read temp if [ "$temp" == "yes" ]; then printf "What is the file system of the root directory? (ext4 or btrfs)\n" read filesystem if [ "$filesystem" == "btrfs" ]; then setup_swapfile btrfs else setup_swapfile ext4 fi create_dir setup_time install_zsh install_podman printf "Finished.\n" else printf "exit.\n" fi