archlinux安装脚本-1-快速安装

系统默认分区:

sda1    swap

sda2    /

sda3    /home

#!/bin/bash
function install_powerpill(){
    cp /etc/pacman.conf /etc/pacman.conf.default
    
    echo "[archlinuxcn]" >> /etc/pacman.conf
    echo "SigLevel = Optional TrustAll" >> /etc/pacman.conf
    echo "Server = http://repo.archlinuxcn.org/$arch" >> /etc/pacman.conf
    
    pacman -Syy
    pacman -S --noconfirm archlinuxcn-keyring
    pacman -S --noconfirm yaourt
    echo 1 | yaourt --noconfirm powerpill
    
    rm -rf /etc/pacman.conf
    cp /etc/pacman.conf.default /etc/pacman.conf
    pacman -Syy
}


function jbase(){
    dialog --backtitle "Archlinux quicklly install script" --clear 
    --title "Description" 
    --yesno "By default: 

    mount sda1 to swap 

    mount sda2 to /  

    mount sda3 to /home 


    Click yes to start install.
Click no to exit
Click esc to reboot" 20 90
    
    respose=$?
    case $respose in
    0)
    ;;
    1)
    exit 1
    ;;
    *)
    reboot;;
    esac
    
    #mount
    mkswap /dev/sda1
    swapon /dev/sda1
    mkfs.ext4 -F /dev/sda2
    mkfs.ext4 -F /dev/sda3
    mount /dev/sda2 /mnt
    mkdir /mnt/home
    mount /dev/sda3 /mnt/home
    
    echo "copy usr"
    cp -a /usr /mnt
    echo "copy bin"
    cp -a /bin /mnt
    echo "copy lib"
    cp -a /lib /mnt
    echo "copy lib64"
    cp -a /lib64 /mnt
    echo "copy sbin"
    cp -a /sbin /mnt
    echo "copy etc"
    cp -a /etc /mnt
    echo "copy home"
    cp -a /home /mnt
    echo "copy opt"
    cp -a /opt /mnt
    echo "copy root"
    cp -a /root /mnt
    echo "copy srv"
    cp -a /srv /mnt
    echo "copy var"
    cp -a /var /mnt
    
    echo "mkdir boot"
    mkdir -vm755 /mnt/boot
    echo "mkdir dev"
    mkdir -vm755 /mnt/dev
    echo "mkdir run"
    mkdir -vm755 /mnt/run
    echo "mkdir mnt"
    mkdir -vm755 /mnt/mnt
    echo "cp vmlinuz-linux "
    cp -vaT /run/archiso/bootmnt/arch/boot/$(uname -m)/vmlinuz /mnt/boot/vmlinuz-linux
    echo "mkdir /mnt/tmp"
    mkdir -vm1777 /mnt/tmp
    echo "mkdir /mnt/sys"
    mkdir -vm555 /mnt/sys
    echo "mkdir /mnt/proc"
    mkdir -vm555 /mnt/proc
    
    #set fstab
    echo "make fstab "
    genfstab -p /mnt >> /mnt/etc/fstab
    
    cp -a ${0} /mnt/root
    
    #Chroot
    clear
    echo "/root/${0} jconfig to continue"
    arch-chroot /mnt
    
    umount -R /mnt
    systemctl reboot
}

function install_software(){
    clear
    if dialog --backtitle "Configure" --title "Install software" 
    --checklist "Click space to select or deselect ,enter to confirm ,click other to cancel" 20 90 20 
    libreoffice "office" on
    abiword "office work" on
    gnumeric "office excel" on
    adwaita-icon-theme  "" on 
    evince "pdf reader" on
    faience-icon-theme "icon theme" on
    fcitx "input method" off
    fcitx-im "input method" off
    fcitx-configtool "input method" off
    fcitx-sunpinyin "input method" off
    ibus "input method" on
    ibus-qt "input method" on
    ibus-pinyin "input method" on
    firefox "web brower" on
    epiphany "web brower" off
    flashplugin "brower plugin" on
    gftp "ftp client" on
    gimp "picture editor" on
    git "" on
    gnome-mplayer  "video player" off
    vlc "video player" on 
    parole "video player" on 
    gnome-screenshot "" off
    gstreamer0.10-plugins "" on
    gtk-engines "" on
    gvfs "" on
    gvfs-mtp "" on
    lightdm-gtk-greeter-settings "" on 
    lxde "desktop environment" on
    cinnamon "desktop environment" off
    xfce4 "desktop environment" off
    mate "desktop environment" off
    plasma "desktop environment" off
    gnome "desktop environment" off
    enlightenment "desktop environment" off
    cairo-dock "customer desktop-taskbar" off
    plank "customer desktop-taskbar" off
    tint2 "customer desktop-taskbar" off
    awesome "customer desktop-window manager" off
    lxterminal "customer desktop-terminal emulator" off
    medit "editor" on
    network-manager-applet "" on
    networkmanager-openconnect "" on
    networkmanager-openvpn "" on
    networkmanager-pptp "" on
    networkmanager-vpnc "" on
    ntfs-3g "" on
    numlockx "" off
    openssh "" on
    p7zip "" on
    plank "" off
    thunderbird "" off
    udisks2 "" on
    unrar "" on
    unzip "" on
    virtualbox "" on
    virtualbox-host-modules "" on
    wiznote "" on
    xarchiver "" off
    xcompmgr "" off
    zip "" on
    2>/tmp/jarch/software.txt
    then
    dialog --backtitle "Configure" --title "Install software" --infobox "ing..." 20 90
    install_powerpill
    powerpill -S --noconfirm mesa
    powerpill -S --noconfirm wqy-microhei
    powerpill -S --noconfirm ttf-dejavu
    powerpill -S --noconfirm xf86-video-vesa
    powerpill -S --noconfirm xf86-input-evdev
    powerpill -S --noconfirm xorg-xinit
    powerpill -S --noconfirm xorg-server
    powerpill -S --noconfirm alsa-utils
    powerpill -S --noconfirm ntfs-3g gvfs
    powerpill -S --noconfirm lightdm lightdm-gtk-greeter
    systemctl enable lightdm
       selections=`cat /tmp/jarch/software.txt`
    for i in $selections ; do
    powerpill -S --noconfirm $i
    done
    fi
}

function jconfig(){
    mkdir /tmp/jarch
    
    #add packages source
    mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.default
    echo "Server = http://mirrors.aliyun.com/archlinux/$repo/os/$arch" > /etc/pacman.d/mirrorlist
    echo "Server = http://mirror.bit.edu.cn/archlinux/$repo/os/$arch" >> /etc/pacman.d/mirrorlist
    echo "Server = http://mirrors.163.com/archlinux/$repo/os/$arch" >> /etc/pacman.d/mirrorlist
    echo "Server = http://mirrors.sohu.com/archlinux/$repo/os/$arch" >> /etc/pacman.d/mirrorlist
    echo "Server = http://mirrors.yun-idc.com/archlinux/$repo/os/$arch" >> /etc/pacman.d/mirrorlist
    echo "Server = http://ftp.sjtu.edu.cn/archlinux/$repo/os/$arch" >> /etc/pacman.d/mirrorlist
    echo "Server = http://mirrors.4.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch" >> /etc/pacman.d/mirrorlist
    echo "Server = http://mirror.lzu.edu.cn/archlinux/$repo/os/$arch" >> /etc/pacman.d/mirrorlist
    echo "update packages"
    pacman -Syy
    
    echo "rebuild log"
    sed -i 's/Storage=volatile/#Storage=auto/' /etc/systemd/journald.conf
    
    echo "disable some autostart"
    systemctl disable pacman-init.service choose-mirror.service
    rm -r /etc/systemd/system/choose-mirror.service
    rm -r /etc/systemd/system/pacman-init.service
    rm -r /etc/systemd/system/etc-pacman.d-gnupg.mount
    rm -r /etc/systemd/system/getty@tty1.service.d
    rm /etc/systemd/scripts/choose-mirror
    
    
    echo "delete some useless"
    rm /etc/systemd/system/getty@tty1.service.d/autologin.conf
    rm /root/.automated_script.sh
    rm /root/.zlogin
    rm /etc/sudoers.d/g_wheel
    rm /etc/mkinitcpio-archiso.conf
    pacman -R --noconfirm archiso
    
    
    chmod 700 /root
    
    #delete user arch
    userdel -r arch
    
    #init
    clear
    mkinitcpio -p linux
    
    #locale
    clear
    echo "locale-gen"
    echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
    echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen
    locale-gen
    echo "make language "
    echo.UTF-8 > /etc/locale.conf
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    echo "make time"
    hwclock --systohc --utc
    
    #GRUB
    clear
    echo "install and config grub"
    pacman -S --noconfirm grub
    grub-install /dev/sda
    grub-mkconfig -o /boot/grub/grub.cfg
    
    #network
    clear
    echo "auto start network"
    pacman -S --noconfirm networkmanager
    systemctl enable NetworkManager
    
    #start graphical
    systemctl set-default graphical.target
    systemctl enable lightdm
    
    #pc name
    clear
    dialog --backtitle "Configure" --title "pc" 
    --inputbox "Enter the pc name." "Archlinux" 20 90 2>/tmp/jarch/pc.txt
    case $? in
    0)
    pcname=$( /etc/hostname
    ;;
    *)
    echo Archlinux > /etc/hostname
    ;;
    esac
    
    #root password
    clear
    dialog --backtitle "Configure" --title "root passowrd" 
    --insecure --passwordbox "enter the root password" 20 90 2>/tmp/jarch/rootpw.txt
    case $? in
    0)
    rootpwd=$( /dev/null
    ;;
    *)
    echo 'no'
    ;;
    esac
    
    #new user
    pacman -S --noconfirm sudo
    pacman -S --noconfirm zsh
    rm -rf /etc/skel/*
    echo "autoload -U compinit promptinit" > .zshrc
    echo "compinit" >> .zshrc
    echo "promptinit" >> .zshrc
    echo "prompt adam2" >> .zshrc
    echo ""
    echo 'bindkey "e[1~" beginning-of-line # Home' >> .zshrc
    echo 'bindkey "e[4~" end-of-line # End' >> .zshrc
    echo 'bindkey "e[5~" beginning-of-history # PageUp' >> .zshrc
    echo 'bindkey "e[6~" end-of-history # PageDown' >> .zshrc
    echo 'bindkey "e[2~" quoted-insert # Ins' >> .zshrc
    echo 'bindkey "e[3~" delete-char # Del' >> .zshrc
    
    
    clear
    dialog --backtitle "Configure" --title "user" 
    --inputbox "Enter the new user name." "arch" 20 90 2>/tmp/jarch/newuser.txt
    case $? in
    0)
    newuser=$(/tmp/jarch/userpw.txt
    case $? in
    0)
    userpwd=$( /dev/null
    
    echo "${newuser} ALL=(ALL) ALL" >> /etc/sudoer
    echo "Defaults:${newuser} timestamp_timeout=22" >> /etc/sudoer
    echo "Defaults rootpw" >> /etc/sudoer
    
    #install software
    pacman -Rscn -noconfirm elinks
    pacman -Rscn -noconfirm nmap
    install_software
    
    clear
    echo "Delete something"
    mkdir /tmp/jarch
    pacman -Rscn --noconfirm dialog
    
    clear
    echo "Install over . Input exit and click enter to reboot"
    exit 0
}



if [ -z $1 ]
then
    dialog_install=`pacman -Qi dialog 2> /dev/null`
    if [ -z "$dialog_install" ]
    then
        jconfig
    else
    jbase
fi
else
    $@
fi


转载于:https://my.oschina.net/jonetwelve/blog/617177

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值