This commit is contained in:
Thomas Forgione 2025-05-03 16:20:02 +02:00
parent 235e2b7402
commit 70838875e6
3 changed files with 94 additions and 28 deletions

View File

@ -15,6 +15,23 @@ RUN echo "cat tforgione.sh | bash" > /home/tester/.bash_history
CMD ["bash"] CMD ["bash"]
# Test on ubuntu
FROM ubuntu:24.04 AS ubuntu-user
RUN \
apt update -y && \
apt install sudo curl -y && \
useradd -m tester && \
echo tester:tester | chpasswd && \
usermod -aG sudo tester
USER tester
WORKDIR /home/tester
COPY ./tforgione.sh /home/tester/tforgione.sh
RUN echo "cat tforgione.sh | bash" > /home/tester/.bash_history
CMD ["bash"]
# Test on archlinux # Test on archlinux
FROM archlinux AS archlinux-user FROM archlinux AS archlinux-user

View File

@ -5,6 +5,11 @@ debian() {
docker container run -it debian-user bash docker container run -it debian-user bash
} }
ubuntu() {
docker build . --tag ubuntu-user --target ubuntu-user --debug
docker container run -it ubuntu-user bash
}
archlinux() { archlinux() {
docker build . --tag archlinux-user --target archlinux-user --debug docker build . --tag archlinux-user --target archlinux-user --debug
docker container run -it archlinux-user bash docker container run -it archlinux-user bash

View File

@ -61,7 +61,7 @@ should_install_neovim=0
should_install_rust=0 should_install_rust=0
should_install_nodejs=0 should_install_nodejs=0
should_install_python=0 should_install_python=0
should_install_hyrpland=0 should_install_hyprland=0
find_os() { find_os() {
apt --version > /dev/null 2>&1 apt --version > /dev/null 2>&1
@ -205,9 +205,8 @@ debug() {
} }
run() { run() {
packags=() packages=()
python_packages=(pip) python_packages=()
python_packages+=(venv)
if [ $should_install_git -eq 1 ]; then if [ $should_install_git -eq 1 ]; then
packages+=(git) packages+=(git)
@ -217,28 +216,22 @@ run() {
packages+=(zsh) packages+=(zsh)
fi fi
if [ $should_install_dotfiles -eq 1 ]; then if [ $should_install_neovim -eq 1 ]; then
if [ $has_pacman -eq 1 ]; then
packages+=(neovim) packages+=(neovim)
fi fi
fi
if [ $should_install_nodejs -eq 1 ]; then if [ $should_install_nodejs -eq 1 ]; then
packages+=(nodejs) packages+=(nodejs)
packages+=(npm)
fi
if [ $should_install_rust -eq 1 ]; then if [ $has_pacman -eq 1 ]; then
if [ $has_apt -eq 1 ]; then packages+=(npm)
packages+=(build-essential)
packages+=(pkg-config)
packages+=(libssl-dev)
elif [ $has_pacman -eq 1 ]; then
packages+=(base)
packages+=(base-devel)
fi fi
fi fi
if [ $should_install_python ]; then if [ $should_install_python ]; then
# Install python
if [ $has_apt -eq 1 ]; then if [ $has_apt -eq 1 ]; then
packages+=(python3) packages+=(python3)
packages+=(python-is-python3) packages+=(python-is-python3)
@ -246,9 +239,13 @@ run() {
packages+=(python3-venv) packages+=(python3-venv)
elif [ $has_pacman -eq 1 ]; then elif [ $has_pacman -eq 1 ]; then
packages+=(python) packages+=(python)
packages+=(python-venv)
fi fi
# Install some python plugins that work well with neovim if necessary
if [ $should_install_neovim -eq 1 ]; then
python_packages+=(pycodestyle)
python_packages+=("python-lsp-server[all]")
fi
fi fi
if [ $should_install_hyprland -eq 1 ]; then if [ $should_install_hyprland -eq 1 ]; then
@ -265,13 +262,35 @@ run() {
python_packages+=(psutil) python_packages+=(psutil)
fi fi
# Add apt repository for recent nodejs for debian
if [ $should_install_nodejs -eq 1 ] && [ $has_apt -eq 1 ]; then
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo bash
fi
if [ $has_apt -eq 1 ]; then if [ $has_apt -eq 1 ]; then
sudo apt install -y ${packages[@]} sudo apt install -y ${packages[@]}
if [ $should_install_neovim ]; then
# Install neovim from github to get latest version
curl -L https://github.com/neovim/neovim/releases/download/stable/nvim-linux-x86_64.tar.gz -o tmp.tar.gz
sudo tar xf tmp.tar.gz -C / --strip-components=1
rm tmp.tar.gz
fi
elif [ $has_pacman -eq 1 ]; then elif [ $has_pacman -eq 1 ]; then
sudo pacman -Sy ${packages[@]} --noconfirm sudo pacman -Sy ${packages[@]} --noconfirm --needed
fi fi
if [ $should_install_dotfiles ]; then
sudo chsh $USER -s /bin/zsh
fi
# Prepare venv for python
if [ $should_install_python -eq 1 ]; then
python -m venv $HOME/.venv
VIRTUAL_ENV=$HOME/.venv $HOME/.venv/bin/pip install ${python_packages[@]}
fi
# Configure dotfiles
if [ $should_install_dotfiles -eq 1 ]; then if [ $should_install_dotfiles -eq 1 ]; then
if [ ! -d $HOME/.config/ohmyzsh ]; then if [ ! -d $HOME/.config/ohmyzsh ]; then
git clone https://github.com/ohmyzsh/ohmyzsh $HOME/.config/ohmyzsh git clone https://github.com/ohmyzsh/ohmyzsh $HOME/.config/ohmyzsh
@ -279,11 +298,9 @@ run() {
if [ ! -d $HOME/.config/dotfiles ]; then if [ ! -d $HOME/.config/dotfiles ]; then
git clone https://gitea.tforgione.fr/tforgione/dotfiles $HOME/.config/dotfiles git clone https://gitea.tforgione.fr/tforgione/dotfiles $HOME/.config/dotfiles
fi fi
sudo chsh $USER -s /bin/zsh
ln -s $HOME/.config/dotfiles/zshrc $HOME/.zshrc ln -s $HOME/.config/dotfiles/zshrc $HOME/.zshrc
if [ $should_install_update_remainder -eq 1 ]; then if [ $should_install_update_remainder -eq 1 ]; then
echo "# Checks that the update is done weekly, if its not done, prints a nice message" >> $HOME/.config/dotfiles/zsh/extraconfig.zsh echo "# Checks that the update is done weekly, if its not done, prints a nice message" >> $HOME/.config/dotfiles/zsh/extraconfig.zsh
@ -295,14 +312,16 @@ run() {
fi fi
fi fi
if [ $should_install_nodejs -eq 1 ]; then # Configure hyprland
mkdir -p $HOME/.npmbin if [ $should_install_hyprland -eq 1 ]; then
npm config set prefix $HOME/.npmbin ln -s $HOME/.config/dotfiles/hypr $HOME/.config/hypr
npm install -g npm ln -s $HOME/.config/dotfiles/hypr/waybar $HOME/.config/waybar
sudo apt purge npm -y
sudo apt autoremove -y touch $HOME/.config/dotfiles/hypr/exec-once.conf
touch $HOME/.config/dotfiles/hypr/monitors.conf
fi fi
# Configure neovim
if [ $should_install_neovim -eq 1 ]; then if [ $should_install_neovim -eq 1 ]; then
# Create config files an directories # Create config files an directories
mkdir -p $HOME/.nvim/backups $HOME/.nvim/swp $HOME/.nvim/undo mkdir -p $HOME/.nvim/backups $HOME/.nvim/swp $HOME/.nvim/undo
@ -317,11 +336,18 @@ run() {
nvim +PlugInstall +qa nvim +PlugInstall +qa
fi fi
# Configure nodejs
if [ $should_install_nodejs -eq 1 ]; then
mkdir -p $HOME/.npmbin
npm config set prefix $HOME/.npmbin
npm install -g npm
fi
# Configure rust
if [ $should_install_rust -eq 1 ]; then if [ $should_install_rust -eq 1 ]; then
curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path -y curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path -y
export PATH=$HOME/.cargo/bin:$PATH export PATH=$HOME/.cargo/bin:$PATH
rustup component add rust-analyzer rustup component add rust-analyzer
cargo install cargo-update
fi fi
} }
@ -340,6 +366,21 @@ banner() {
echo -e "└───────────────────────────────────────────────────────────────────────────────────────────┘\x1b[0m" echo -e "└───────────────────────────────────────────────────────────────────────────────────────────┘\x1b[0m"
} }
ending_banner() {
echo -e "\x1b[32;1m┌───────────────────────────────────────────────────────────────────────────────────────────┐"
echo "│ _ __ _ _ _ _ _ _ │"
echo "│ | | / _| (_) ( ) (_) | | | | | │"
echo "│ | |_| |_ ___ _ __ __ _ _ ___ _ __ ___|/ ___ _ _ __ ___| |_ __ _| | | ___ _ __ │"
echo "│ | __| _/ _ \| '__/ _\` | |/ _ \| '_ \ / _ \ / __| | | '_ \/ __| __/ _\` | | |/ _ \ '__| │"
echo "│ | |_| || (_) | | | (_| | | (_) | | | | __/ \__ \ | | | | \__ \ || (_| | | | __/ | │"
echo "│ \__|_| \___/|_| \__, |_|\___/|_| |_|\___| |___/ |_|_| |_|___/\__\__,_|_|_|\___|_| │"
echo "│ __/ | │"
echo "│ |___/ │"
echo "├───────────────────────────────────────────────────────────────────────────────────────────┤"
echo "│ TFORGIONE'S DOTFILES INSTALLED! HAVE A GREAT DAY! │"
echo -e "└───────────────────────────────────────────────────────────────────────────────────────────┘\x1b[0m"
}
main() { main() {
banner banner
find_os find_os
@ -351,11 +392,14 @@ main() {
ask_for_dotfiles ask_for_dotfiles
ask_for_neovim ask_for_neovim
ask_for_rust ask_for_rust
ask_for_python
ask_for_nodejs ask_for_nodejs
ask_for_hyprland ask_for_hyprland
debug debug
run run
ending_banner
} }
main < /dev/tty main < /dev/tty