Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Verify what nodejs name is
Browse files Browse the repository at this point in the history
Linux distros may change the name of nodejs binary file,it was found two names: "
node" or "nodejs".
The script has to identify which name of the nodejs binary is being used before
continuing.

Also, depending on the distro sh files may change and it is more secure to use
/bin/bash than /bin/sh. For compatibility purposes

Signed-off-by: Bruno Bottazzini <[email protected]>
  • Loading branch information
Bruno Bottazzini committed Aug 25, 2015
1 parent d39ded3 commit 38ec20b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
24 changes: 19 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# This file is part of the Soletta Project
#
Expand Down Expand Up @@ -35,6 +35,8 @@ print_need_dep () {
}

RETVAL=0
SYSTEMD_SERVICE_PATH="/etc/systemd/system"

test_dep () {
SILENT=$2
PKG_NAME=$3
Expand Down Expand Up @@ -65,6 +67,9 @@ fi
test_dep "node" 1
if [ $RETVAL -eq 1 ]; then
test_dep "nodejs" 0 "nodejs"
NODE_BIN_NAME="nodejs"
else
NODE_BIN_NAME="node"
fi

test_dep "sol-fbp-runner" 1
Expand All @@ -78,20 +83,29 @@ test_dep "dot" 0 "graphviz"

test_dep "npm" 0 "npm"

test_dep "bower" 1
test_dep "bower" 1 2>/dev/null
if [ $RETVAL -eq 1 ]; then
print_need_dep "bower"
echo "sudo npm install -g bower"
exit 1
else
BOWER=$(bower -v)
if [ -z "$BOWER" ]; then
echo "If you are running distro debian based machine run:"
echo "sudo apt-get install nodejs-legacy"
exit 1
fi
fi

npm install
bower install

echo "Installing required services..."
SERVER_PATH=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
su -c "cp $SERVER_PATH/scripts/units/[email protected] /lib/systemd/system/"
su -c "cp $SERVER_PATH/scripts/units/soletta-dev-app-server.service.in /lib/systemd/system/soletta-dev-app-server.service"
su -c "sed -i "s@PATH@"$SERVER_PATH"@" /lib/systemd/system/soletta-dev-app-server.service"
su -c "cp $SERVER_PATH/scripts/units/[email protected] $SYSTEMD_SERVICE_PATH/ &&
cp $SERVER_PATH/scripts/units/soletta-dev-app-server.service.in $SYSTEMD_SERVICE_PATH/soletta-dev-app-server.service &&
sed -i "s@PATH@"$SERVER_PATH"@" $SYSTEMD_SERVICE_PATH/soletta-dev-app-server.service &&
sed -i "s@"NODE_BIN_NAME"@"$NODE_BIN_NAME"@" $SYSTEMD_SERVICE_PATH/soletta-dev-app-server.service"
systemctl daemon-reload
echo "to start server run:"
echo "systemctl start soletta-dev-app-server"
Expand Down
2 changes: 1 addition & 1 deletion scripts/fbp-runner.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# This file is part of the Soletta Project
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/units/soletta-dev-app-server.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=Run Soletta Development Application server
After=warn-boot.service

[Service]
ExecStart=/usr/bin/node PATH/server/app.js 1> /dev/null 2>&1
ExecStart=/usr/bin/NODE_BIN_NAME PATH/server/app.js 1> /dev/null 2>&1
Environment="NODE_ENV=production"

[Install]
Expand Down

0 comments on commit 38ec20b

Please sign in to comment.