aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhumphreylin <[email protected]>2019-09-04 14:02:45 +0800
committerhumphreylin <[email protected]>2019-09-04 14:02:45 +0800
commitfc794b336adcde4d5de407e44b686eb5beb16ef7 (patch)
tree67e0783fe663e06e4b88f3067c56232d520c4981
parent04ddc2c59ce3d693a338a379e8afb302c1a6ab27 (diff)
downloaddotfiles-fc794b336adcde4d5de407e44b686eb5beb16ef7.tar.gz
dotfiles-fc794b336adcde4d5de407e44b686eb5beb16ef7.tar.bz2
dotfiles-fc794b336adcde4d5de407e44b686eb5beb16ef7.zip
Add a install.sh
-rw-r--r--install.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/install.sh b/install.sh
new file mode 100644
index 0000000..9dd046d
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+# install.sh
+
+check_is_sudo() {
+ if [ "$EUID" -ne 0 ]; then
+ echo "Please run as root."
+ exit
+ fi
+}
+
+usage() {
+ echo "Usage: sudo bash install.sh [OPTION]"
+ echo " base - install base pkgs"
+ echo " dotfiles - get dotfiles from GitHub and set soft links"
+ echo " all - install all things listed above"
+}
+
+base_install() {
+ echo "--------- Install Base Packages Now ---------"
+ if command -v apt > /dev/null; then
+ apt install git \
+ curl \
+ cmake \
+ build-essential \
+ python3-dev \
+ autojump \
+ zsh
+ fi
+}
+
+get_dotfiles() {
+ # create subshell
+ (
+ echo "--------- Get Dotfiles Now ---------"
+
+ read -r -p "It will remove the dotfiles folder if it exists and overwrite all dotfiles. Are you sure? [y/N] " response
+ response=${response,,} # tolower
+ if [[ "$response" =~ ^(yes|y)$ ]]; then
+
+ cd "$HOME"
+ rm -rf dotfiles
+ git clone [email protected]:humpylin/dotfiles.git
+
+ rm -rf .vimrc .tmux.conf .bashrc .zshrc .gitconfig
+ ln -s dotfiles/.vimrc .vimrc
+ ln -s dotfiles/.tmux.conf .tmux.conf
+ ln -s dotfiles/.bashrc .bashrc
+ ln -s dotfiles/.gitconfig .gitconfig
+ ln -s dotfiles/.zshrc .zshrc
+ fi
+ )
+}
+
+main() {
+ local cmd=$1
+
+ if [[ -z "$cmd" ]]; then
+ usage
+ exit 1
+ fi
+
+ check_is_sudo
+
+ if [[ $cmd == all ]]; then
+ base_install
+ get_dotfiles
+ fi
+}
+
+main "$@"