-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·68 lines (52 loc) · 1.94 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·68 lines (52 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -e
# if [ "$EUID" -ne 0 ]; then
# echo "Please run as root"
# exit
# fi
if [ "$(uname -s)" = "Linux" ]; then
export OPERATING_SYSTEM="linux"
fi
if [ "$(uname -s)" = "Darwin" ]; then
export OPERATING_SYSTEM="macos"
fi
export GLOBAL_BASHRC_FILE="$HOME/.bashrc"
export GLOBAL_BASH_RC_BACKUP="$HOME/.bashrc.backup"
export GLOBAL_CUSTOM_BINS_DIR="$HOME/.bin"
export GLOBAL_BASH_RC_GENERATED_FILE="$HOME/.bashrc_profile_generated"
# Create a backup of the existing .bashrc file
cat $GLOBAL_BASHRC_FILE > $GLOBAL_BASH_RC_BACKUP
if grep -q "source $GLOBAL_BASH_RC_GENERATED_FILE" $GLOBAL_BASHRC_FILE; then
sed -i -e "/.bashrc_profile_generated/d" $GLOBAL_BASHRC_FILE
fi
# check if $GLOBAL_BASH_RC_GENERATED_FILE exists
if [ -f $GLOBAL_BASH_RC_GENERATED_FILE ]; then
rm $GLOBAL_BASH_RC_GENERATED_FILE
fi
# Create the .bashrc_profile_generated file
touch $GLOBAL_BASH_RC_GENERATED_FILE
echo "Adding custom binaries to PATH..."
./bin/$OPERATING_SYSTEM/bootstrap.sh
echo "Adding custom binaries to PATH... [DONE]"
echo "Configure settings..."
./config/$OPERATING_SYSTEM/bootstrap.sh
echo "Configure settings... [DONE]"
echo "Installing custom packages..."
sudo ./packages/$OPERATING_SYSTEM/bootstrap.sh
echo "Installing custom packages... [DONE]"
echo "Creating custom aliases, variables and functions..."
./core/$OPERATING_SYSTEM/bootstrap.sh
echo "Creating custom aliases, variables and functions... [DONE]"
# Attach GLOBAL_BASH_RC_GENERATED_FILE to PATH variable
echo "export PATH=$GLOBAL_CUSTOM_BINS_DIR:\$PATH" >> $GLOBAL_BASH_RC_GENERATED_FILE
# Restore the backup of the existing .bashrc file
cat $GLOBAL_BASH_RC_BACKUP > $GLOBAL_BASHRC_FILE
# Add the line "source $GLOBAL_BASH_RC_GENERATED_FILE" to the .bashrc file
echo "Applying changes..."
echo "source $GLOBAL_BASH_RC_GENERATED_FILE" >> $GLOBAL_BASHRC_FILE
echo "Applying changes... [DONE]"
echo ""
echo ""
echo "For applying changes, please run 'source $GLOBAL_BASHRC_FILE'"
echo ""
echo ""