mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
feat(install): Do distro specific setup before installing os-packages
This commit is contained in:
@@ -1,115 +0,0 @@
|
|||||||
#!/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 "$@"
|
|
||||||
@@ -2,29 +2,48 @@
|
|||||||
|
|
||||||
OS_PACKAGE_FILE=package-list-os
|
OS_PACKAGE_FILE=package-list-os
|
||||||
|
|
||||||
|
setup() {
|
||||||
OS_INSTALL_COMMAND=""
|
OS_INSTALL_COMMAND=""
|
||||||
OS_PKG_CHECK_COMMAND=""
|
OS_PKG_CHECK_COMMAND=""
|
||||||
|
|
||||||
os_check() {
|
|
||||||
# TODO: Apply pre-processing to each.
|
|
||||||
# - Install apt specific things: apt-transport-https, sudo apt-get update && sudo apt-get upgrade -y
|
|
||||||
# - Improve dnf download speed by pre-applying required config
|
|
||||||
# Detect package manager and set package manager commands
|
# Detect package manager and set package manager commands
|
||||||
if command -v apt-get > /dev/null 2>&1; then
|
if command -v apt-get > /dev/null 2>&1; then
|
||||||
OS_INSTALL_COMMAND="apt-get update && sudo apt-get upgrade -y && sudo apt-get"
|
OS_INSTALL_COMMAND="apt-get"
|
||||||
OS_PKG_CHECK_COMMAND="apt-cache show"
|
OS_PKG_CHECK_COMMAND="apt-cache show"
|
||||||
elif command -v yum > /dev/null 2>&1; then
|
|
||||||
OS_INSTALL_COMMAND="yum"
|
apt_setup
|
||||||
OS_PKG_CHECK_COMMAND="yum list available"
|
|
||||||
elif command -v dnf > /dev/null 2>&1; then
|
elif command -v dnf > /dev/null 2>&1; then
|
||||||
OS_INSTALL_COMMAND="dnf"
|
OS_INSTALL_COMMAND="dnf"
|
||||||
OS_PKG_CHECK_COMMAND="dnf list available"
|
OS_PKG_CHECK_COMMAND="dnf list available"
|
||||||
|
|
||||||
|
dnf_setup
|
||||||
|
elif command -v yum > /dev/null 2>&1; then
|
||||||
|
OS_INSTALL_COMMAND="yum"
|
||||||
|
OS_PKG_CHECK_COMMAND="yum list available"
|
||||||
else
|
else
|
||||||
log "Unsupported package manager. This script supports apt, yum, and dnf."
|
log "Unsupported package manager. This script supports apt, yum, and dnf."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dnf_setup() {
|
||||||
|
# Faster dnf installs
|
||||||
|
echo "fastestmirror=True" | sudo tee -a /etc/dnf/dnf.conf > /dev/null
|
||||||
|
echo "max_parallel_downloads=10" | sudo tee -a /etc/dnf/dnf.conf > /dev/null
|
||||||
|
echo "defaultYes=True" | sudo tee -a /etc/dnf/dnf.conf > /dev/null
|
||||||
|
echo "keepcache=True" | sudo tee -a /etc/dnf/dnf.conf > /dev/null
|
||||||
|
|
||||||
|
# Enable RPM Fusion & Install media codecs
|
||||||
|
sudo dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm && sudo dnf groupupdate -y core multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin sound-and-video
|
||||||
|
|
||||||
|
sudo dnf update -y
|
||||||
|
}
|
||||||
|
|
||||||
|
apt_setup() {
|
||||||
|
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y apt-transport-https
|
||||||
|
# Add PPAs here
|
||||||
|
}
|
||||||
|
|
||||||
input_file_check() {
|
input_file_check() {
|
||||||
if [ ! -f "$OS_PACKAGE_FILE" ]; then
|
if [ ! -f "$OS_PACKAGE_FILE" ]; then
|
||||||
echo "File not found: $OS_PACKAGE_FILE"
|
echo "File not found: $OS_PACKAGE_FILE"
|
||||||
@@ -69,8 +88,8 @@ print_summary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
os_check
|
|
||||||
input_file_check
|
input_file_check
|
||||||
|
setup
|
||||||
install_os_packages
|
install_os_packages
|
||||||
print_summary "OS" "$os_not_found_packages"
|
print_summary "OS" "$os_not_found_packages"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# - Update `bootstrap-dotfiles.sh` to work from its parent directory & ignore "scripts" directory
|
|
||||||
# - Integrate with `bootstrap-dotfiles.sh` -> do dotfiles 1st, then install
|
|
||||||
# - README.md
|
|
||||||
# - Needs manual installation: appimagelauncher, firefox, brave, vs-code, cursor, kitty, mattermost-desktop, skypedesktop, ulauncher, dotnet8, dotnet8-sdk8.0, aspnetcore-runtime-8.0, Jetbrains Toolbox, Obsidian, Postman, firefox, zen, zoho, zoho-workdrive, nala
|
# - Needs manual installation: appimagelauncher, firefox, brave, vs-code, cursor, kitty, mattermost-desktop, skypedesktop, ulauncher, dotnet8, dotnet8-sdk8.0, aspnetcore-runtime-8.0, Jetbrains Toolbox, Obsidian, Postman, firefox, zen, zoho, zoho-workdrive, nala
|
||||||
# - Available on some, not on others; may need manual installation: libreoffice, sublime-text, kitty-terminfo
|
# - Available on some, not on others; may need manual installation: libreoffice, sublime-text, kitty-terminfo, imagemagick
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
./install-os-packages.sh
|
./install-os-packages.sh
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# Lines that start with # are ignored
|
# Lines that start with # are ignored
|
||||||
apt-transport-https
|
|
||||||
bash
|
bash
|
||||||
bleachbit
|
bleachbit
|
||||||
build-essential
|
build-essential
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ dist-ssr
|
|||||||
nvim_switch/
|
nvim_switch/
|
||||||
*kitty/*.py
|
*kitty/*.py
|
||||||
|
|
||||||
|
.git/
|
||||||
README.md
|
README.md
|
||||||
.gitignore
|
.gitignore
|
||||||
.prettierrc
|
.prettierrc
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#FROM kdeneon/plasma
|
#FROM kdeneon/plasma
|
||||||
#FROM debian:11-slim
|
FROM debian:11-slim
|
||||||
#FROM debian:12-slim
|
#FROM debian:12-slim
|
||||||
#FROM ubuntu:20.04
|
#FROM ubuntu:20.04
|
||||||
#FROM ubuntu:22.04
|
#FROM ubuntu:22.04
|
||||||
#FROM ubuntu:22.10
|
|
||||||
#FROM ubuntu:23.04
|
#FROM ubuntu:23.04
|
||||||
FROM fedora:40
|
#FROM fedora:40
|
||||||
#TODO: Arch
|
#TODO: Arch
|
||||||
WORKDIR /scripts
|
WORKDIR /dotfiles
|
||||||
#RUN apt-get update -y && apt-get install sudo -y # for debian distros
|
RUN apt-get update && apt-get install sudo -y # for debian distros
|
||||||
RUN dnf install sudo -y # for fedora and its derivatives
|
#RUN dnf install sudo -y # for fedora and its derivatives
|
||||||
COPY . .
|
COPY . .
|
||||||
CMD [ "sh", "install.sh" ]
|
CMD [ "sh", "setup.sh", "-i" ]
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
# Prune, build and run docker
|
# Prune, build and run docker
|
||||||
main() {
|
main() {
|
||||||
cd .. # change docker build context to 1 directory up
|
cd ../.. # change docker context to dotfile repo
|
||||||
docker container prune -f && echo "Removed old Docker containers"
|
docker container prune -f && echo "Removed old Docker containers"
|
||||||
docker build -t dotfile-install-test:latest -f test/Dockerfile . && echo "Docker build success"
|
docker build -t dotfile-setup:latest -f scripts/test/Dockerfile . && echo "Docker build success"
|
||||||
docker run -it dotfile-install-test:latest
|
docker run -it dotfile-setup:latest
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user