Skip to content

Commit f41f636

Browse files
Fix Linux installer script.
1 parent e89edb8 commit f41f636

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

docs/install.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
# error handling
44
set -e
5-
set -u
5+
# set -u
66

77
# constants
8-
APP_NAME="FuckingNode"
9-
CLI_NAME="fuckingnode"
10-
INSTALL_DIR="/usr/local/$CLI_NAME"
11-
EXE_PATH="$INSTALL_DIR/$CLI_NAME"
8+
INSTALL_DIR="/usr/local/fuckingnode"
9+
EXE_PATH="/usr/local/fuckingnode/fuckingnode"
1210

1311
# get where we are so it knows what to use
1412
get_platform_arch() {
@@ -121,10 +119,10 @@ create_shortcuts() {
121119

122120
for name in "${!commands[@]}"; do
123121
cmd=${commands[$name]}
124-
script_path="$INSTALL_DIR/$name.sh"
122+
script_path="$INSTALL_DIR/$name"
125123

126124
echo "#!/bin/bash" | sudo tee "$script_path" >/dev/null
127-
echo "\"\$(dirname \"\$0\")/$CLI_NAME\" $cmd \"\$@\"" | sudo tee -a "$script_path" >/dev/null
125+
echo "\"\$(dirname \"\$0\")/fuckingnode\" $cmd \"\$@\"" | sudo tee -a "$script_path" >/dev/null
128126

129127
sudo chmod +x "$script_path"
130128

@@ -150,25 +148,31 @@ add_app_to_path() {
150148
# define target files
151149
FILES=("$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.profile")
152150

153-
local MODIFIED=false
151+
local modified=0
152+
153+
modified=0
154154

155155
# append to each file if it exists and doesn't already contain the entry
156156
for file in "${FILES[@]}"; do
157157
if [ -f "$file" ]; then
158-
if ! grep -q "export PATH=\"$INSTALL_DIR:\$PATH\"" "$file"; then
158+
if ! grep -q "$INSTALL_DIR" "$file"; then
159159
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >>"$file"
160-
MODIFIED=true
160+
echo "Added $INSTALL_DIR to PATH in $file"
161+
modified=1
161162
else
162163
echo "$INSTALL_DIR is already in $file."
163164
fi
165+
else
166+
echo "File $file not found."
164167
fi
165168
done
166169

167170
# apply changes if any file was modified
168-
if [ "$MODIFIED" = true ]; then
169-
source "$HOME/.profile" 2>/dev/null
170-
source "$HOME/.bashrc" 2>/dev/null
171-
source "$HOME/.bash_profile" 2>/dev/null
171+
if (( modified == 1 )); then
172+
echo "Reloading shell config files..."
173+
source "$HOME/.profile" 2>/dev/null || true
174+
source "$HOME/.bashrc" 2>/dev/null || true
175+
source "$HOME/.bash_profile" 2>/dev/null || true
172176
echo "Successfully added $INSTALL_DIR to PATH."
173177
else
174178
echo "No PATH was modified."
@@ -177,10 +181,11 @@ add_app_to_path() {
177181

178182
# installer itself
179183
installer() {
180-
echo "Hi! We'll install $APP_NAME ($ARCH edition) for you. Just a sec!"
184+
echo "Hi! We'll install FuckingNode ($ARCH edition) for you. Just a sec!"
181185
echo ""
182186
echo "Please note we'll use sudo a lot (many files to be created)."
183187
echo "They're all found at $INSTALL_DIR."
188+
echo "(Don't run the script itself with sudo)."
184189
echo ""
185190
echo "This script relies on you running from Bash 4 or later."
186191
echo ""

0 commit comments

Comments
 (0)