@@ -13,7 +13,6 @@ dbsync_latest_version() {
13
13
#
14
14
# Outputs the location to DB Sync depending on:
15
15
# * The availability of $GIT_SOURCE
16
- # * The method used ("script" or "git" in the script, defaults to "git")
17
16
#
18
17
dbsync_source () {
19
18
local DBSYNC_METHOD
@@ -44,7 +43,7 @@ do_install() {
44
43
}
45
44
else
46
45
# Cloning to $INSTALL_DIR
47
- echo " => Downloading db0sync from git to '$INSTALL_DIR '"
46
+ echo " => Downloading db-sync from git to '$INSTALL_DIR '"
48
47
command printf ' \r=> '
49
48
mkdir -p " ${INSTALL_DIR} "
50
49
if [ " $( ls -A " ${INSTALL_DIR} " ) " ]; then
@@ -85,7 +84,33 @@ do_install() {
85
84
if ! command git --git-dir=" $INSTALL_DIR " /.git --work-tree=" $INSTALL_DIR " gc --auto --aggressive --prune=now ; then
86
85
echo >&2 " Your version of git is out of date. Please update it!"
87
86
fi
88
- return
87
+
88
+ local PROFILE_INSTALL_DIR
89
+ PROFILE_INSTALL_DIR=" $( dbsync_install_dir | command sed " s:^$HOME :\$ HOME:" ) "
90
+ SOURCE_STR=" \\ nexport DBSYNC_DIR=\" ${PROFILE_INSTALL_DIR} \"\\ nif [ -f \"\$ DBSYNC_DIR/db-sync.sh\" ]; then\\ n\t export PATH=\" $INSTALL_DIR :\$ PATH\"\\ nfi # This loads db-sync\\ n"
91
+ local DBSYNC_PROFILE
92
+ DBSYNC_PROFILE=" ${HOME} /.bashrc"
93
+
94
+ if ! command grep -qc ' /db-sync.sh' " ${DBSYNC_PROFILE} " ; then
95
+ echo " => Appending db-sync source string to ${DBSYNC_PROFILE} "
96
+ command printf " ${SOURCE_STR} " >> " ${DBSYNC_PROFILE} "
97
+ else
98
+ echo " => db-sync source string already in ${DBSYNC_PROFILE} "
99
+ fi
100
+
101
+ \. " ${DBSYNC_PROFILE} "
102
+
103
+ dbsync_reset
104
+
105
+ echo " => Close and reopen your terminal to start using db-sync.sh"
106
+ }
107
+
108
+ #
109
+ # Unsets the various functions defined
110
+ # during the execution of the install script
111
+ #
112
+ dbsync_reset () {
113
+ unset -f dbsync_install_dir dbsync_latest_version dbsync_source do_install
89
114
}
90
115
91
116
do_install
0 commit comments