mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
feat(install): Script to automate application installation
- Install all required applications to setup a personal machine with just a single command - TODO: Some applications, available only with ppa aren't yet configured to be installed. Next time.
This commit is contained in:
115
scripts/bootstrap.sh
Executable file
115
scripts/bootstrap.sh
Executable file
@@ -0,0 +1,115 @@
|
||||
#!/bin/sh
|
||||
|
||||
# TODO: Use this to better manage dotfiles
|
||||
# https://github.com/dylanirlbeck/dotfiles/blob/master/scripts/bootstrap.sh
|
||||
|
||||
##################################
|
||||
# Parse script arguments
|
||||
##################################
|
||||
|
||||
# defaults
|
||||
QUIET="n"
|
||||
CREATE_LINKS="y"
|
||||
|
||||
usage() {
|
||||
if [ "$1" != "" ]; then
|
||||
echo ""
|
||||
echo -e "${CRED}$1${CEND}\n"
|
||||
fi
|
||||
|
||||
echo "Applies all settings stored in the script's directory to your home directory"
|
||||
echo ""
|
||||
echo "Usage: $0 [-q|--quiet] [-l|--create-links]"
|
||||
echo " -q, --quiet No screen outputs"
|
||||
echo " -l, --create-links Applied by default. Creates soft-links to files in the current directory instead of copying them"
|
||||
|
||||
echo ""
|
||||
echo "Example: $0 -q --create-links"
|
||||
}
|
||||
|
||||
place_dotfile_at_target_location() {
|
||||
source_file_location="$1"
|
||||
file_target_location="$2"
|
||||
TS="$3"
|
||||
|
||||
# To avoid over writing existing dot file, we rename them
|
||||
# Appending the timestamp to file name
|
||||
if [ -f "$file_target_location" ] || [ -L "$file_target_location" ]; then
|
||||
# echo "mv ${file_target_location} ${file_target_location}_${TS}" && [[ "$QUIET" == "n" ]] && echo "Existing dotfile renamed to ${file_target_location}_${TS}"
|
||||
mv "$file_target_location" "${file_target_location}_${TS}" && [ "$QUIET" = "n" ] && echo "Existing setting renamed to ${file_target_location}_${TS}"
|
||||
fi
|
||||
|
||||
target_directory=$(dirname "$file_target_location")
|
||||
if [ ! -d "$target_directory" ]; then
|
||||
mkdir -p "$target_directory" && [ "$QUIET" = "n" ] && echo "Directory ${target_directory} created"
|
||||
fi
|
||||
|
||||
if [ "$CREATE_LINKS" = "y" ]; then
|
||||
# echo "ln -s ${source_file_location} ${target_directory}"
|
||||
ln -sf "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Linked ${file_target_location}"
|
||||
else
|
||||
# echo "cp ${source_file_location} ${target_directory}"
|
||||
cp "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Copied ${file_target_location}"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
while [ "${#}" -gt 0 ]; do
|
||||
case $1 in
|
||||
-q | --quiet)
|
||||
QUIET="y"
|
||||
shift
|
||||
;;
|
||||
-l | --create-links)
|
||||
CREATE_LINKS="y"
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
echo
|
||||
usage
|
||||
echo
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
usage "Unknown parameter passed: $1" "h"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case $(uname -a) in
|
||||
Linux*)
|
||||
# TODO: Make it less KDE-Neon specific and more towards general Linux
|
||||
OS="kde-neon"
|
||||
|
||||
[ "$XDG_CURRENT_DESKTOP" = "KDE" ] && OS="kde-neon"
|
||||
;;
|
||||
Darwin*)
|
||||
OS="macos"
|
||||
;;
|
||||
*)
|
||||
OS="UNSUPPORTED"
|
||||
;;
|
||||
esac
|
||||
|
||||
TS=$(date '+%d_%m_%Y-%H_%M_%S')
|
||||
|
||||
# Switch inside dotfile repository directory
|
||||
cd -P "$(dirname "$0")" || exit
|
||||
|
||||
# Copy all files in "Common" dotfiles to $HOME directory ("~")
|
||||
find "./common" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file; do
|
||||
file_target_location="${HOME}${file#./common}"
|
||||
source_file_location="${PWD}${file#.}"
|
||||
place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS"
|
||||
done
|
||||
|
||||
# Copy platform specific files to $HOME directory ("~")
|
||||
find "./${OS}" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file; do
|
||||
file_target_location="${HOME}${file#./"${OS}"}"
|
||||
source_file_location="${PWD}${file#.}"
|
||||
place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS"
|
||||
done
|
||||
}
|
||||
|
||||
main "$@"
|
||||
38
scripts/brew-package-list
Normal file
38
scripts/brew-package-list
Normal file
@@ -0,0 +1,38 @@
|
||||
# Lines that start with # are ignored
|
||||
bat
|
||||
bats-core
|
||||
dnscrypt-proxy
|
||||
docker
|
||||
docker-compose
|
||||
fd
|
||||
font-caskaydia-mono-nerd-font
|
||||
font-fira-code-nerd-font
|
||||
font-fira-mono-nerd-font
|
||||
font-hasklug-nerd-font
|
||||
font-inconsolata-nerd-font
|
||||
font-jetbrains-mono-nerd-font
|
||||
font-liberation-nerd-font
|
||||
font-symbols-only-nerd-font
|
||||
fzf
|
||||
go
|
||||
jq
|
||||
lazydocker
|
||||
lazygit
|
||||
lua
|
||||
luajit
|
||||
lua-language-server
|
||||
n
|
||||
neovim
|
||||
prettierd
|
||||
python@3.12
|
||||
rclone
|
||||
shellcheck
|
||||
shodan
|
||||
speedtest-cli
|
||||
sqlite
|
||||
tlrc
|
||||
tokei
|
||||
tree-sitter
|
||||
yt-dlp
|
||||
zsh-autosuggestions
|
||||
zsh-syntax-highlighting
|
||||
11
scripts/docker-test.sh
Executable file
11
scripts/docker-test.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# script to build and run docker
|
||||
|
||||
main() {
|
||||
docker container prune -f && echo "Removed old Docker containers"
|
||||
docker build -f ../Dockerfile -t dotfile-install-test:latest .. && echo "Docker build success"
|
||||
docker run -it dotfile-install-test:latest
|
||||
}
|
||||
|
||||
main "$@"
|
||||
33
scripts/install.sh
Executable file
33
scripts/install.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# TODO:
|
||||
# - Display log or show instruction to see the logs
|
||||
# - Add logs to a file
|
||||
# - How to manage/recover from installation issues
|
||||
|
||||
# TODO: ppa: brave, vs-code, cursor, kitty, libreoffice, mattermost-desktop, skypedesktop, ulauncher, code, dotnet8, dotnet8-sdk8.0, aspnetcore-runtime-8.0, sublime-text, AppImage Launcher Settings, Jetbrains Toolbox, Obsidian, Postman, firefox, zen, zoho, zoho-workdrive
|
||||
|
||||
install_os_packages() {
|
||||
# Install packages listed on "os-package-list" file
|
||||
# Ignore lines that start with #
|
||||
OS_PACKAGES=$(sed "/^#/d" os-package-list | tr "\n\r" " ")
|
||||
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get install $OS_PACKAGES -y
|
||||
}
|
||||
|
||||
install_brew_packages() {
|
||||
# Install packages listed on "brew-package-list" file
|
||||
# Ignore lines that start with #
|
||||
yes | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> "$HOME"/.bashrc
|
||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||
brew tap homebrew/linux-fonts # Required for nerd fonts
|
||||
BREW_PACKAGES=$(sed "/^#/d" brew-package-list | tr "\n\r" " ")
|
||||
brew install $BREW_PACKAGES
|
||||
}
|
||||
|
||||
main() {
|
||||
install_os_packages
|
||||
# install_brew_packages
|
||||
}
|
||||
|
||||
main "$@"
|
||||
43
scripts/os-package-list
Normal file
43
scripts/os-package-list
Normal file
@@ -0,0 +1,43 @@
|
||||
# Lines that start with # are ignored
|
||||
# TODO: use apt to check if the package is available. if not, remove them from list before installing
|
||||
apt-transport-https
|
||||
bash
|
||||
bleachbit
|
||||
build-essential
|
||||
ca-certificates
|
||||
clang
|
||||
curl
|
||||
evolution-ews
|
||||
dolphin
|
||||
dolphin-plugins
|
||||
ffmpeg
|
||||
flameshot
|
||||
gcc
|
||||
gdb
|
||||
git
|
||||
gparted
|
||||
htop
|
||||
imagemagick
|
||||
kde-spectacle
|
||||
kdeconnect
|
||||
llvm
|
||||
make
|
||||
net-tools
|
||||
okular
|
||||
python3
|
||||
python3-pip
|
||||
ripgrep
|
||||
simplescreenrecorder
|
||||
smplayer
|
||||
software-properties-common
|
||||
solaar
|
||||
syncthing
|
||||
tmux
|
||||
ufw
|
||||
vim
|
||||
vim-common
|
||||
vim-tiny
|
||||
vlc
|
||||
wget
|
||||
xclip
|
||||
zsh
|
||||
Reference in New Issue
Block a user