🔥 Remove Ubuntu-specific code.

This commit is contained in:
punkfairie 2024-02-11 10:31:33 -08:00
parent 606a42a5a9
commit a2dac20a5f
No known key found for this signature in database
GPG key ID: 0858B0F48128A755
4 changed files with 143 additions and 172 deletions

View file

@ -12,6 +12,4 @@ npm_install "gulp CLI" gulp-cli
if [ "$(uname)" = Darwin ]
brew_install WebStorm webstorm --cask
else if [ "$(uname)" = Linux ] && cmd_exists snap
execute "sudo snap install webstorm --classic" WebStorm
end

View file

@ -36,29 +36,4 @@ if [ "$(uname)" = Darwin ]
# Utilities.
brew_install "The Unarchiver" the-unarchiver --cask
else if [ "$(uname)" = Linux ] && cmd_exists snap
# Networking.
if ! cmd_exists windscribe
execute "sudo wget https://github.com/Windscribe/Desktop-App/releases/download/v2.8.6/windscribe_2.8.6_amd64.deb -O /tmp/ws.deb \
&& sudo apt install /tmp/ws.deb" \
Windscribe
end
execute "sudo snap install firefox" Firefox
execute "sudo snap install qbittorrent-arnatious" qBittorrent
# Social.
execute "sudo snap install discord" Discord
# TODO: add check for already installed.
execute "sudo wget https://github.com/BetterDiscord/Installer/releases/latest/download/BetterDiscord-Linux.AppImage -O /tmp/bd.AppImage \
&& sudo chmod u+x /tmp/bd.AppImage \
&& /tmp/bd.AppImage" \
BetterDiscord
# Productivity.
execute "sudo snap install obsidian --classic" Obsidian
# Media.
execute "sudo snap install vlc" VLC
end

View file

@ -13,6 +13,4 @@ brew_install Meilisearch meilisearch "" "" true
if [ "$(uname)" = Darwin ]
brew_install "Laravel Herd" herd --cask
brew_install PhpStorm phpstorm --cask
else if [ "$(uname)" = Linux ] && cmd_exists snap
execute "sudo snap install phpstorm --classic" PhpStorm
end

View file

@ -16,108 +16,108 @@ yes_to_all=false
################################################################################
download() {
url="$1"
output="$2"
url="$1"
output="$2"
if command -v "curl" >/dev/null 2>&1; then
curl \
--location \
--silent \
--show-error \
--output "$output" \
"$url" \
>/dev/null 2>&1
if command -v "curl" >/dev/null 2>&1; then
curl \
--location \
--silent \
--show-error \
--output "$output" \
"$url" \
>/dev/null 2>&1
return $?
return $?
elif command -v "wget" >/dev/null 2>&1; then
wget \
--quiet \
--output-document="$output" \
"$url" \
>/dev/null 2>&1
elif command -v "wget" >/dev/null 2>&1; then
wget \
--quiet \
--output-document="$output" \
"$url" \
>/dev/null 2>&1
return $?
fi
return $?
fi
return 1
return 1
}
download_utils() {
tmp_file="$(mktemp /tmp/XXXXX)"
tmp_file="$(mktemp /tmp/XXXXX)"
# shellcheck source=/dev/null
download "$DOTFILES_UTILS" "$tmp_file" &&
. "$tmp_file" &&
rm -rf "$tmp_file" &&
return 0
# shellcheck source=/dev/null
download "$DOTFILES_UTILS" "$tmp_file" &&
. "$tmp_file" &&
rm -rf "$tmp_file" &&
return 0
return 1
return 1
}
extract() {
archive="$1"
output_dir="$2"
archive="$1"
output_dir="$2"
if command -v "tar" >/dev/null 2>&1; then
tar \
--extract \
--gzip \
--file "$archive" \
--strip-components 1 \
--directory "$output_dir"
if command -v "tar" >/dev/null 2>&1; then
tar \
--extract \
--gzip \
--file "$archive" \
--strip-components 1 \
--directory "$output_dir"
return $?
fi
return $?
fi
return 1
return 1
}
download_dotfiles() {
print_title "Download and extract dotfiles archive"
print_title "Download and extract dotfiles archive"
tmp_file="$(mktemp /tmp/XXXXX)"
tmp_file="$(mktemp /tmp/XXXXX)"
download "$DOTFILES_TARBALL" "$tmp_file"
print_result $? "Download archive" "true"
printf "\n"
download "$DOTFILES_TARBALL" "$tmp_file"
print_result $? "Download archive" "true"
printf "\n"
if ! $yes_to_all; then
if ! $yes_to_all; then
while [ -e "$DOT" ]; do
ask "'$DOT' already exists, do you want to (o)verwrite or (b)ackup the existing directory?"
answer="$(get_answer)"
while [ -e "$DOT" ]; do
ask "'$DOT' already exists, do you want to (o)verwrite or (b)ackup the existing directory?"
answer="$(get_answer)"
case $answer in
o)
rm -rf "$DOT"
break
;;
b)
mv "$DOT" "$DOT.bak"
break
;;
*) print_warning "Please enter a valid option." ;;
esac
case $answer in
o)
rm -rf "$DOT"
break
;;
b)
mv "$DOT" "$DOT.bak"
break
;;
*) print_warning "Please enter a valid option." ;;
esac
done
done
else
rm -rf "$DOT" >/dev/null 2>&1
fi
else
rm -rf "$DOT" >/dev/null 2>&1
fi
mkdir -p "$DOT"
print_result $? "Create '$DOT'" "true"
mkdir -p "$DOT"
print_result $? "Create '$DOT'" "true"
# Extract archive.
extract "$tmp_file" "$DOT"
print_result $? "Extract archive" "true"
# Extract archive.
extract "$tmp_file" "$DOT"
print_result $? "Extract archive" "true"
rm -rf "$tmp_file"
print_result $? "Remove archive"
rm -rf "$tmp_file"
print_result $? "Remove archive"
cd "$DOT/script" ||
return 1
cd "$DOT/script" ||
return 1
}
################################################################################
@ -125,23 +125,23 @@ download_dotfiles() {
################################################################################
are_xcode_cli_tools_installed() {
xcode-select --print-path >/dev/null 2>&1
xcode-select --print-path >/dev/null 2>&1
}
install_xcode_cli_toools() {
if [ "$(uname)" = "Darwin" ]; then
if [ "$(uname)" = "Darwin" ]; then
print_title "Xcode"
print_title "Xcode"
xcode-select --install >/dev/null 2>&1
xcode-select --install >/dev/null 2>&1
execute \
"until are_xcode_cli_tools_installed; do sleep 5; done" \
"Install Xcode Command Line Tools"
execute \
"until are_xcode_cli_tools_installed; do sleep 5; done" \
"Install Xcode Command Line Tools"
sudo xcodebuild -license accept >/dev/null 2>&1
print_result $? "Agree to the terms of the Xcode license"
fi
sudo xcodebuild -license accept >/dev/null 2>&1
print_result $? "Agree to the terms of the Xcode license"
fi
}
################################################################################
@ -149,30 +149,30 @@ install_xcode_cli_toools() {
################################################################################
setup_gitconfig() {
cd "$DOT" || return
cd "$DOT" || return
if ! [ -f "$DOT/git/.gitconfig.local.symlink" ]; then
print_title "Set up gitconfig"
if ! [ -f "$DOT/git/.gitconfig.local.symlink" ]; then
print_title "Set up gitconfig"
git_credential="cache"
git_credential="cache"
if [ "$(uname)" = "Darwin" ]; then
git_credential="osxkeychain"
fi
if [ "$(uname)" = "Darwin" ]; then
git_credential="osxkeychain"
fi
print_question "What is your Github author name?"
read -r git_authorname
print_question "What is your Github author name?"
read -r git_authorname
print_question "What is your Github author email?"
read -r git_authoremail
print_question "What is your Github author email?"
read -r git_authoremail
sed -e "s/AUTHORNAME/$git_authorname/g" \
-e "s/AUTHOREMAIL/$git_authoremail/g" \
-e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" \
"$DOT/git/.gitconfig.local.symlink.example" >"$DOT/.gitconfig.local.symlink"
sed -e "s/AUTHORNAME/$git_authorname/g" \
-e "s/AUTHOREMAIL/$git_authoremail/g" \
-e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" \
"$DOT/git/.gitconfig.local.symlink.example" >"$DOT/.gitconfig.local.symlink"
print_result $? "gitconfig"
fi
print_result $? "gitconfig"
fi
}
################################################################################
@ -180,20 +180,20 @@ setup_gitconfig() {
################################################################################
git_init() {
print_title "Initialize Git repository"
print_title "Initialize Git repository"
if [ -z "$DOTFILES_ORIGIN" ]; then
print_error "Please provide a URL for the Git origin"
return 1
fi
if [ -z "$DOTFILES_ORIGIN" ]; then
print_error "Please provide a URL for the Git origin"
return 1
fi
if ! is_git_repository; then
cd "$DOT" || print_error "Failed to cd $DOT"
if ! is_git_repository; then
cd "$DOT" || print_error "Failed to cd $DOT"
execute \
"git init && git remote add origin $DOTFILES_ORIGIN" \
"Initialize the dotfiles Git repository"
fi
execute \
"git init && git remote add origin $DOTFILES_ORIGIN" \
"Initialize the dotfiles Git repository"
fi
}
################################################################################
@ -201,57 +201,57 @@ git_init() {
################################################################################
main() {
if [ "$(uname)" != "Linux" ] && [ "$(uname)" != "Darwin" ]; then
printf "Sorry, this script is intended only for macOS and Ubuntu!"
return 1
fi
if [ "$(uname)" != "Linux" ] && [ "$(uname)" != "Darwin" ]; then
printf "Sorry, this script is intended only for macOS and Linux!"
return 1
fi
# Load utils.
# Load utils.
if [ -x "${DOT}/script/utils.sh" ]; then
. "${DOT}/script/utils.sh" || exit 1
else
download_utils || exit 1
fi
if [ -x "${DOT}/script/utils.sh" ]; then
. "${DOT}/script/utils.sh" || exit 1
else
download_utils || exit 1
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
skip_questions "$@" &&
yes_to_all=true
skip_questions "$@" &&
yes_to_all=true
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ask_for_sudo
ask_for_sudo
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Check if this script was run directly, and if not, dotfiles will need to be
# downloaded.
# Check if this script was run directly, and if not, dotfiles will need to be
# downloaded.
printf "%s" "$(sh_source "$0")" | grep "bootstrap.sh" >/dev/null 2>&1 ||
download_dotfiles
printf "%s" "$(sh_source "$0")" | grep "bootstrap.sh" >/dev/null 2>&1 ||
download_dotfiles
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setup_gitconfig
setup_gitconfig
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
install_xcode_cli_toools
install_xcode_cli_toools
"$DOT/homebrew/brew.sh"
"$DOT/homebrew/brew.sh"
"$DOT/git/git.sh"
"$DOT/git/git.sh"
"$DOT/fish/fish.sh"
"$DOT/fish/fish.sh"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if cmd_exists "git"; then
if [ "$(git config --get remote.origin.url)" != "$DOTFILES_ORIGIN" ]; then
git_init
fi
fi
if cmd_exists "git"; then
if [ "$(git config --get remote.origin.url)" != "$DOTFILES_ORIGIN" ]; then
git_init
fi
fi
}
main "$@"