This script installs Gentoo for you. Yes I am making this and it takes hours help~
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

255 lines
6.2 KiB

#!/bin/bash
BLACK="\033[0;30m"
BLUE="\033[0;34m"
GREEN="\033[0;32m"
CYAN="\033[0;36m"
RED="\033[0;31m"
PURPLE="\033[0;35m"
BROWN="\033[0;33m"
BLUE="\033[0;34m"
GREEN="\033[0;32m"
CYAN="\033[0;36m"
RED="\033[0;31m"
PURPLE="\033[0;35m"
BROWN="\033[0;33m"
RESET="\033[0m"
DIALOG_BACKTITLE="xSlendiX's Gentoo Installer"
DIALOG=${DIALOG=dialog --clear}
DIALOG_SIZE="20 61"
DIALOG_SIZE_BIG="24 80"
DIALOG_SIZE_S="7 60"
DIALOG_SIZE_TEXT="10 60"
log() {
printf "$BLUE ::$RESET $@\n"
}
error() {
printf "$RED ::$RESET $@"
exit 1
}
if ! dialog > /dev/null ; then
log "Dialog not installed. Installing..."
emerge dialog
fi
ask_questions() {
# Username
while true; do
$DIALOG --backtitle "$DIALOG_BACKTITLE" \
--title "Username" \
--inputbox "What do you wish to be your user account' username?" $DIALOG_SIZE_TEXT 2> /tmp/choice_setup
response=$?
retval=$(cat /tmp/choice_setup)
case $response in
0)
if [[ -n "$retval" ]]; then
USERNAME="$retval"
break
fi
;;
*)
;;
esac
done
# Password
while true; do
$DIALOG --backtitle "$DIALOG_BACKTITLE" --insecure --passwordbox "Enter user password" $DIALOG_SIZE_TEXT 2> /tmp/choice_setup
retval=$?
ANSWER=$(cat /tmp/choice_setup)
if [[ "$retval" -ne 0 ]]; then
continue
fi
$DIALOG --backtitle "$DIALOG_BACKTITLE" --insecure --passwordbox "Enter user password again" $DIALOG_SIZE_TEXT 2> /tmp/choice_setup
retval=$?
ANSWER2=$(cat /tmp/choice_setup)
if [[ "$retval" -ne 0 ]]; then
continue
fi
if [[ "$ANSWER" = "$ANSWER2" ]]; then
PASSWORD="$ANSWER"
break;
else
$DIALOG --backtitle "$DIALOG_BACKTITLE" \
--title "Oops!" \
--msgbox "Passwords do not match! Please try again." $DIALOG_SIZE_S
continue
fi
done
# X11
$DIALOG --backtitle "$DIALOG_BACKTITLE" \
--title "Question" --yesno "Do you use a touchpad?" $DIALOG_SIZE_S
response=$?
case $response in
0)
TOUCHPAD=" synaptics"
;;
*)
TOUCHPAD=""
;;
esac
$DIALOG --backtitle "$DIALOG_BACKTITLE" \
--title "Question" --yesno "Do you use a nVidia?" $DIALOG_SIZE_S
response=$?
case $response in
0)
NVIDIA=1
;;
*)
NVIDIA=0
;;
esac
if [[ "$NVIDIA" -ne 1 ]]; then
$DIALOG --backtitle "$DIALOG_BACKTITLE" \
--title "Question" --yesno "Do you use AMD/ATI?" $DIALOG_SIZE_S
response=$?
case $response in
0)
AMD=1
;;
*)
AMD=0
;;
esac
fi
}
TO_INSTALL=()
install_deps() {
log "Installing dependencies..."
rm -rf /etc/portage/package.use
echo "dev-vcs/subversion perl" >> /etc/portage/package.use
emerge dev-vcs/git dev-python/pip
}
pipinstall() { pip3 install "$1" > /dev/tty8 ;}
gitinstall() {
pname="$(basename "$1" .git)"
srcdir="$repodir/$pname"
echo " :: Installing $pname in $repodir (git/make)"
sudo -u "$USERNAME" git clone --depth 1 "$1" "$srcdir" > /dev/tty8
cd "$srcdir" || error "Could not change directory to $srcdir during installation of $pname!"
sudo -u "$USERNAME" make > /dev/tty8
make install > /dev/tty8
cd /tmp || error "FATAL: Could not change directory to /tmp! Base installation may be broken!"
}
gitinstall2() {
pname="$(basename "$1" .git)"
srcdir="$repodir/$pname"
echo " :: Installing $pname in $repodir (git/make)"
sudo -u "$USERNAME" git clone --depth 1 "$1" "$srcdir" > /dev/tty8
cd "$srcdir" || error "Could not change directory to $srcdir during installation of $pname!"
sudo -u "$USERNAME" ./autogen.sh > /dev/tty8
sudo -u "$USERNAME" ./configure > /dev/tty8
sudo -u "$USERNAME" make > /dev/tty8
make install > /dev/tty8
cd /tmp || error "FATAL: Could not change directory to /tmp! Base installation may be broken!"
}
install_loop() {
TO_INSTALL=()
([ -f "programs.csv" ] && cp "programs.csv" /tmp/prfile.csv) || curl -Ls https://git.xslendi.xyz/xslendix/gentoo_installer/raw/branch/master/programs.csv | sed '/^;/d' > /tmp/prfile.csv
total=$(wc -l /tmp/prfile.csv)
log "Total packages to be installed: $total"
while IFS=, read -r type package comment; do
n=$((n+1))
echo " :: Adding package nr. $n: $package"
echo "$comment" | grep -q "^\".*\"$" && comment="$(echo "$comment" | sed "s/\(^\"\|\"$\)//g")"
case "$type" in
"P") pipinstall "$package" ;;
"G") gitinstall "$package" ;;
"C") gitinstall2 "$package" ;;
*)
TO_INSTALL+="$package"
;;
esac
done < /tmp/prfile.csv
emerge "${TO_INSTALL[@]}"
cat >> make.conf <<EOF
INPUT_DEVICES="libinput$TOUCHPAD"
EOF
if [[ "$NVIDIA" -eq 1 ]]; then
cat >> make.conf <<EOF
VIDEO_CARDS="nouveau"
EOF
fi
if [[ "$AMD" -eq 1 ]]; then
cat >> make.conf <<EOF
VIDEO_CARDS="radeon"
EOF
fi
emerge --autounmask-continue x11-base/xorg-drivers
env-update
source /etc/profile
}
do_rice() {
log "Downloading rice"
sudo -u $USERNAME git clone --depth 1 https://git.xslendi.xyz/xSlendiX/dotfiles /home/$USERNAME/rice
log "Setting up applications"
log "vim-plug"
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
log "Changing shell of $USERNAME"
chsh -s /usr/bin/zsh $USERNAME
sudo -u "$USERNAME" mkdir -p "/home/$USERNAME/.cache/zsh"
log "Installing Oh My Zsh, bloated but who cares I like it"
sudo -u "$USERNAME" sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
log "Installing Oh My Zsh plugins"
sudo -u "$USERNAME" git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions.git .oh-my-zsh/custom/plugins/zsh-autosuggestions
sudo -u "$USERNAME" git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git .oh-my-zsh/custom/plugins/zsh-syntax-highlighting
log "Installing rice"
sudo -u $USERNAME mv -fv ~/rice/* ~/.
sudo -u $USERNAME mv -fv ~/rice/.* ~/.
sudo -u $USERNAME rm -rf ~/.git ~/rice
log "Configuring NeoVim plugins"
sudo -u "$USERNAME" nvim +PlugInstall
log "Blacklisting pcspkr"
rmmod pcspkr
echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf
log "Starting Pulseaudio"
killall pulseaudio; sudo -u "$USERNAME" pulseaudio -D
}
do_services() {
log "Configuring services"
rc-update add acpid default
rc-update add mpd default
rc-update add dbus default
}
ask_questions
install_deps
install_loop
do_rice
do_services
echo "Done! Final restart needed though."