82 lines
3.5 KiB
Bash
82 lines
3.5 KiB
Bash
#!/bin/bash
|
|
loadkeys jp106
|
|
#キーボードを日本語配列へ変更
|
|
printf "Please enter your username\n"
|
|
read -r home_username
|
|
printf "Please enter your password\n"
|
|
read -sr home_password
|
|
printf "Please enter Hostname\n"
|
|
read -r hostname1
|
|
|
|
fdisk -l
|
|
#ディスク一覧表示
|
|
printf "\nWhat disk do you want to install to? example:/dev/sda \n\n"
|
|
read -r installdisk
|
|
#インストールするディスクを入力
|
|
printf "%s is selected as the disk to install. Are you sure you want to perform the partition operation? (yes or no) \n" "$installdisk"
|
|
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:+300M -t 1:ef00 -c 1:"EFI System" "$installdisk"
|
|
sgdisk -n 2:0: -t 2:8300 -c 2:"Linux filesystem" "$installdisk"
|
|
#パーティション操作
|
|
mkfs.vfat -F32 "$d1"
|
|
mkfs.ext4 "$d2"
|
|
#フォーマット
|
|
mount "$d2" /mnt
|
|
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
|
|
pacstrap /mnt base base-devel linux linux-firmware linux-headers grub dosfstools efibootmgr networkmanager dialog nano intel-ucode
|
|
#パッケージインストール
|
|
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"
|
|
fi
|