#!/usr/bin/bash function create_dir () { printf "Create Directory \n" mkdir "$HOME"/.local mkdir "$HOME"/.local/bin mkdir "$HOME"/Temp mkdir "$HOME"/Dev mkdir "$HOME"/Container mkdir "$HOME"/Samba 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 yay -S ttf-meslo-nerd-font-powerlevel10k 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 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 -r swapcap if [ "$1" == "btrfs" ]; then sudo truncate -s 0 /swapfile sudo chattr +C /swapfile sudo fallocate -l "$swapcap"M /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo "#swapfile_autogenerated" | sudo tee -a /etc/fstab echo "/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 || exit sudo pacman -Sy sudo pacman -S --noconfirm git git clone https://aur.archlinux.org/yay.git cd yay || exit makepkg -si cd "$HOME" || exit } 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_ca () { printf "Install CA\n" cd "$HOME"/Temp || exit curl -OLk https://192.168.1.64:8443/www/suti7/tx1310m3_CA.pem sudo trust anchor ./tx1310m3_CA.pem } printf "Do you want to the initial setup? (yes or no)\n" read -r temp if [ "$temp" == "yes" ]; then printf "What is the file system of the root directory? (ext4 or btrfs)\n" read -r filesystem if [ "$filesystem" == "btrfs" ]; then setup_swapfile btrfs else setup_swapfile ext4 fi create_dir setup_time install_fonts install_yay install_zsh install_ca printf "Finished.\n" else printf "exit.\n" fi