Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
#!/bin/sh

systemd=$(pidof systemd)

if [ -z "$systemd" ]; then
echo "Systemd not detected"
echo "Assuming upstart"
startCmd="start paperplane"
stopCmd="stop paperplane"
else
echo "Systemd detected"
startCmd="systemctl start PaperPlane"
stopCmd="systemctl stop PaperPlane"
fi

if [ -d "/var/local/paperplane" ]; then
echo "Updating existing install"
stop paperplane
eval "$stopCmd"
cp -R . /var/local/paperplane
chown -R paperplane:paperplane /var/local/paperplane
start paperplane
eval "$startCmd"
fi

if [ ! -d "/var/local/paperplane" ]; then
# Add user
adduser --system --group --gecos 'User for PaperPlane webapp' --disabled-password --home /home/paperplane paperplane

# Copy upstart config
cp upstart.conf /etc/init/paperplane.conf
if [ -z "$systemd" ]; then
# Copy upstart config
cp upstart.conf /etc/init/paperplane.conf
else
# Copy systemd config
cp systemd.service /usr/lib/systemd/system/PaperPlane.service
# Enable systemd service
systemctl enable PaperPlane
fi

# Copy application folder and create log file
cp -R . /var/local/paperplane
Expand All @@ -24,5 +44,5 @@ if [ ! -d "/var/local/paperplane" ]; then
cd /var/local/paperplane; npm link
chown -R paperplane:paperplane /var/local/paperplane

start paperplane
eval "$startCmd"
fi
14 changes: 14 additions & 0 deletions systemd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=PaperPlane Link Sharing Server
After=network.target local-fs.target nss-lookup.target

[Service]
Type=simple
ExecStart=/usr/bin/node /var/local/paperplane/server.js
#StandardOutput=/var/log/paperplane.log
#Not needed as systemd has it's own logging service
#To view logs use 'systemd status PaperPlane'
#To enable that log file, uncomment the line

[Install]
WantedBy=multi-user.target