@@ -38,7 +38,7 @@ API_URL="https://api.github.com/repos/$REPO/releases/latest"
3838ASSET_URL=$( curl -s " $API_URL " | grep ' browser_download_url' | grep " $BIN_NAME " | head -n1 | cut -d ' "' -f 4)
3939
4040if [ -z " $ASSET_URL " ]; then
41- echo -e " ${RED} Error: Could not find asset $BIN_NAME in the latest release${NC} "
41+ echo " ${RED} Error: Could not find asset $BIN_NAME in the latest release${NC} "
4242 exit 1
4343fi
4444
@@ -47,7 +47,7 @@ curl -sL "$ASSET_URL" -o "$INSTALL_DIR/sitedog"
4747
4848# Check if file was downloaded
4949if [ ! -f " $INSTALL_DIR /sitedog" ]; then
50- echo -e " ${RED} Error: Failed to download sitedog${NC} "
50+ echo " ${RED} Error: Failed to download sitedog${NC} "
5151 exit 1
5252fi
5353
@@ -60,7 +60,7 @@ TPL_NAME="demo.html.tpl"
6060TPL_URL=$( curl -s " $API_URL " | grep ' browser_download_url' | grep " $TPL_NAME " | head -n1 | cut -d ' "' -f 4)
6161
6262if [ -z " $TPL_URL " ]; then
63- echo -e " ${RED} Error: Could not find asset $TPL_NAME in the latest release${NC} "
63+ echo " ${RED} Error: Could not find asset $TPL_NAME in the latest release${NC} "
6464 exit 1
6565fi
6666
@@ -69,29 +69,59 @@ curl -sL "$TPL_URL" -o "$TEMPLATES_DIR/demo.html.tpl"
6969
7070# Check if template was downloaded
7171if [ ! -f " $TEMPLATES_DIR /demo.html.tpl" ]; then
72- echo -e " ${RED} Error: Failed to download demo.html.tpl${NC} "
72+ echo " ${RED} Error: Failed to download demo.html.tpl${NC} "
7373 exit 1
7474fi
7575
7676echo " Installed demo.html.tpl to $TEMPLATES_DIR /demo.html.tpl"
7777
78- # Try to create symlink in /usr/local/bin
79- SYMLINK_OK=0
80- if [ -w /usr/local/bin ]; then
81- ln -sf " $INSTALL_DIR /sitedog" /usr/local/bin/sitedog && SYMLINK_OK=1
82- else
83- if sudo ln -sf " $INSTALL_DIR /sitedog" /usr/local/bin/sitedog; then
84- SYMLINK_OK=1
78+ # Add to PATH if not already there
79+ RELOAD_MSG=" "
80+ PROFILE=" "
81+ # Determine shell profile to update
82+ case " $( basename " $SHELL " ) " in
83+ zsh) PROFILE=" $HOME /.zshrc" ;;
84+ fish) PROFILE=" $HOME /.config/fish/config.fish" ;;
85+ * ) PROFILE=" $HOME /.bashrc" ;;
86+ esac
87+
88+ if ! echo " $PATH " | grep -q " $INSTALL_DIR " ; then
89+ # Add to PATH in the appropriate profile
90+ if [ " $SHELL " = " /usr/bin/fish" ] || [ " $SHELL " = " /bin/fish" ]; then
91+ echo " set -gx PATH \" $INSTALL_DIR \" \$ PATH" >> " $PROFILE "
92+ else
93+ echo " export PATH=\" $INSTALL_DIR :\$ PATH\" " >> " $PROFILE "
8594 fi
95+
96+ RELOAD_MSG=" ${YELLOW} (source $PROFILE or restart your shell)${NC} "
8697fi
8798
88- if [ $SYMLINK_OK -eq 1 ]; then
89- echo " Symlink created: /usr/local/bin/sitedog -> $INSTALL_DIR /sitedog"
99+ echo " ${GREEN} SiteDog has been installed successfully!${NC} "
100+ echo " Installed to: ${INSTALL_DIR} /sitedog${RELOAD_MSG} "
101+
102+ # Ask user if they want to create symlink in /usr/local/bin
103+ echo " "
104+ printf " Create symlink in /usr/local/bin? (sudo) [y/N] "
105+ read -r REPLY
106+
107+ if [ " $REPLY " = " y" ] || [ " $REPLY " = " Y" ] || [ " $REPLY " = " yes" ] || [ " $REPLY " = " YES" ]; then
108+ if sudo ln -sf " $INSTALL_DIR /sitedog" /usr/local/bin/sitedog; then
109+ echo " ${GREEN} 🔗 Symlink created → /usr/local/bin/sitedog${NC} "
110+ else
111+ echo " ${RED} Failed to create symlink${NC} "
112+ fi
90113else
91- echo " ${YELLOW} No permissions to create symlink in /usr/local/bin.${NC} "
92- echo " Please add $INSTALL_DIR to your PATH. For example, add this line to your shell rc file (e.g., ~/.bashrc or ~/.zshrc):"
93- echo ' export PATH="$HOME/.sitedog/bin:$PATH"'
114+ echo " Global symlink skipped."
94115fi
95116
96- echo " ${GREEN} SiteDog has been installed successfully!${NC} "
97- echo " Try: sitedog help"
117+ echo " "
118+ echo " Try: sitedog help"
119+
120+ # Show reload message if PATH was updated
121+ if [ -n " $PROFILE " ]; then
122+ echo " "
123+ echo " ${YELLOW} If 'sitedog help' doesn't work, run:${NC} "
124+ echo " "
125+ echo " source $PROFILE "
126+ echo " "
127+ fi
0 commit comments