Skip to content

Commit 10f2aff

Browse files
committed
Next version of installer ready for testing.
1 parent f084782 commit 10f2aff

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

install.sh

100644100755
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ dbsync_latest_version() {
1313
#
1414
# Outputs the location to DB Sync depending on:
1515
# * The availability of $GIT_SOURCE
16-
# * The method used ("script" or "git" in the script, defaults to "git")
1716
#
1817
dbsync_source() {
1918
local DBSYNC_METHOD
@@ -44,7 +43,7 @@ do_install() {
4443
}
4544
else
4645
# Cloning to $INSTALL_DIR
47-
echo "=> Downloading db0sync from git to '$INSTALL_DIR'"
46+
echo "=> Downloading db-sync from git to '$INSTALL_DIR'"
4847
command printf '\r=> '
4948
mkdir -p "${INSTALL_DIR}"
5049
if [ "$(ls -A "${INSTALL_DIR}")" ]; then
@@ -85,7 +84,33 @@ do_install() {
8584
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --auto --aggressive --prune=now ; then
8685
echo >&2 "Your version of git is out of date. Please update it!"
8786
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
89114
}
90115

91116
do_install

0 commit comments

Comments
 (0)