2024-06-23 20:47:21 +09:00
#!/bin/bash
loadkeys jp106
#キーボードを日本語配列へ変更
2024-07-28 01:27:47 +09:00
printf "\nPlease enter your username\n"
2024-06-23 20:47:21 +09:00
read -r home_username
2024-07-28 01:27:47 +09:00
printf "Please enter your password\n"
2024-06-23 20:47:21 +09:00
read -sr home_password
2024-07-28 01:27:47 +09:00
printf "Please enter Hostname\n"
2024-06-23 20:47:21 +09:00
read -r hostname1
fdisk -l
#ディスク一覧表示
2024-07-28 01:27:47 +09:00
printf "\nWhat disk do you want to install to? example:/dev/sda \n"
2024-06-23 20:47:21 +09:00
read -r installdisk
2024-07-28 01:27:47 +09:00
printf "Choose the file system to use for your root partition. (ext4, btrfs)\n"
2024-06-23 20:47:21 +09:00
read -r filesystem
2024-07-28 01:27:47 +09:00
printf "Choose the kernel you want to use. (linux, zen, lts)\n"
2024-06-23 20:47:21 +09:00
read -r kernel
#インストールするディスクを入力
2024-07-28 01:27:47 +09:00
printf "%s (%s) is selected as the disk to install. Are you sure you want to perform the partition operation? (yes or no) \n" " $installdisk " " $filesystem "
2024-06-23 20:47:21 +09:00
read -r check1
#インストールするディスクを確認
if [ " $check1 " = = "yes" ] ; then
printf "%s" " $installdisk " >> ./installdisk.txt
if [ " $( grep "nvme" -rl ./installdisk.txt) " = = "./installdisk.txt" ] ; then
d1 = " ${ installdisk } p1 "
d2 = " ${ installdisk } p2 "
elif [ " $( grep "mmcblk" -rl ./installdisk.txt) " = = "./installdisk.txt" ] ; then
d1 = " ${ installdisk } p1 "
d2 = " ${ installdisk } p2 "
else
d1 = " ${ installdisk } 1 "
d2 = " ${ installdisk } 2 "
fi
#1,2の番号をつけるのとディスクの種類を判断
sgdisk -o " $installdisk " -g
sgdisk -n 1:0:+1024M -t 1:ef00 -c 1:"EFI System" " $installdisk "
sgdisk -n 2:0: -t 2:8300 -c 2:"Linux filesystem" " $installdisk "
#パーティション操作
mkfs.vfat -F32 " $d1 "
if [ " $filesystem " = = "ext4" ] ; then
mkfs.ext4 " $d2 "
2024-07-28 01:27:47 +09:00
mount " $d2 " /mnt
2024-06-23 20:47:21 +09:00
elif [ " $filesystem " = = "btrfs" ] ; then
mkfs.btrfs -f " $d2 "
2024-07-28 01:27:47 +09:00
mount " $d2 " /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@swap
umount " $d2 "
mount " $d2 " /mnt -o subvol = @
mkdir /mnt/home
mkdir /mnt/swap
mount " $d2 " /mnt/home -o subvol = @home
mount " $d2 " /mnt/swap -o subvol = @swap
2024-06-23 20:47:21 +09:00
else
mkfs.ext4 " $d2 "
2024-07-28 01:27:47 +09:00
mount " $d2 " /mnt
2024-06-23 20:47:21 +09:00
fi
#フォーマット
mkdir /mnt/boot
mount " $d1 " /mnt/boot
#マウント
reflector --sort rate --country jp --latest 10 --save /etc/pacman.d/mirrorlist
#ミラーリストかえたい!!
pacman -Sy
pacman -S --noconfirm archlinux-keyring
if [ " $kernel " = = "linux" ] ; then
pacstrap /mnt base base-devel linux linux-firmware linux-headers btrfs-progs ntfs-3g exfatprogs grub dosfstools efibootmgr networkmanager dialog vi nano intel-ucode
elif [ " $kernel " = = "zen" ] ; then
pacstrap /mnt base base-devel linux-zen linux-firmware linux-zen-headers btrfs-progs ntfs-3g exfatprogs grub dosfstools efibootmgr networkmanager dialog vi nano intel-ucode
elif [ " $kernel " = = "lts" ] ; then
pacstrap /mnt base base-devel linux-lts linux-firmware linux-lts-headers btrfs-progs ntfs-3g exfatprogs grub dosfstools efibootmgr networkmanager dialog vi nano intel-ucode
else
pacstrap /mnt base base-devel linux linux-firmware linux-headers btrfs-progs ntfs-3g exfatprogs grub dosfstools efibootmgr networkmanager dialog vi nano intel-ucode
fi
#パッケージインストール
genfstab -U /mnt >> /mnt/etc/fstab
#fstab作成
arch-chroot /mnt /usr/bin/sed -i -e 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
arch-chroot /mnt /usr/bin/sed -i -e 's/#ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/g' /etc/locale.gen
#localeの設定
arch-chroot /mnt /usr/bin/locale-gen
#localeの設定適用
printf "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
#LANG環境変数設定
printf "[Time]\nNTP=ntp.nict.jp" > /mnt/etc/systemd/timesyncd.conf
#NTPサーバー書き込み
arch-chroot /mnt /usr/bin/grub-install --target= x86_64-efi --efi-directory= /boot --bootloader-id= arch --recheck
arch-chroot /mnt /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
#grubインストール
arch-chroot /mnt /usr/bin/systemctl enable NetworkManager.service
#NetworkManager有効化
printf "KEYMAP=jp106" > /mnt/etc/vconsole.conf
#日本語配列の設定
printf "%s" " $hostname1 " > /mnt/etc/hostname
#ホストネームを変更
arch-chroot /mnt /usr/bin/useradd -d /home/" $home_username " -m " $home_username "
printf "%s" " $home_password " | arch-chroot /mnt /usr/bin/passwd --stdin " $home_username "
#ユーザー作成とパスワード設定
arch-chroot /mnt /usr/bin/usermod -aG wheel " $home_username "
#wheelグループへ所属
arch-chroot /mnt /usr/bin/sed -i -e 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/g' /etc/sudoers
curl -Lk 'https://192.168.1.64:8443/www/suti7/arch/initial.sh' -o " /mnt/home/ $home_username /initial.sh "
chown 1000:1000 " /mnt/home/ $home_username /initial.sh "
chmod 700 " /mnt/home/ $home_username /initial.sh "
#visudo設定
printf "\n\nInstallation is complete. Please reboot.\n"
else
printf "Installation canceled. \n"
2024-07-28 01:27:47 +09:00
fi