Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
ssh-tunnel-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
ssh-tunnel-manager
Commits
b2a085f2
Commit
b2a085f2
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Update to run as a different user
parent
77403780
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ssh-tunnel-manager.sysv-init.sh
+62
-41
62 additions, 41 deletions
ssh-tunnel-manager.sysv-init.sh
with
62 additions
and
41 deletions
ssh-tunnel-manager.sysv-init.sh
+
62
−
41
View file @
b2a085f2
...
@@ -19,48 +19,69 @@
...
@@ -19,48 +19,69 @@
# Description: SSH-Tunnel-Manager to manager multiple SSH connections to different servers.
# Description: SSH-Tunnel-Manager to manager multiple SSH connections to different servers.
### END INIT INFO
### END INIT INFO
# Source function library.
.
/lib/lsb/init-functions
#. /etc/rc.d/init.d/functions
exec
=
"/usr/sbin/ssh-tunnel-manager"
NAME
=
ssh-tunnel-manager
prog
=
"ssh-tunnel-manager"
USER
=
root
config
=
"/etc/ssh-tunnel-manager.conf"
DAEMON
=
"/usr/local/bin/
${
NAME
}
"
CONFIG
=
"/etc/ssh-tunnel-manager.conf"
PIDFILE
=
"/var/run/
${
NAME
}
.pid"
# Overrides
[
-f
"/etc/default/
$NAME
"
]
&&
.
/etc/default/
$NAME
start
()
{
# If the daemon is not there, then exit.
[
-x
$exec
]
||
exit
5
test
-x
$DAEMON
||
exit
5
[
-f
$config
]
||
exit
6
$exec
start
}
stop
()
{
case
$1
in
$exec
stop
start
)
}
# Checked the PID file exists and check the actual status of process
if
[
-e
$PIDFILE
]
;
then
restart
()
{
status_of_proc
-p
$PIDFILE
$DAEMON
"
$NAME
process"
&&
status
=
"0"
||
status
=
"
$?
"
$exec
restart
# If the status is SUCCESS then don't need to start again.
}
if
[
$status
=
"0"
]
;
then
exit
# Exit
rh_status
()
{
fi
$exec
status
fi
}
# Start the daemon.
log_daemon_msg
"Starting the process"
"
$NAME
"
# Start the daemon with the help of start-stop-daemon
case
"
$1
"
in
# Log the message appropriately
start
)
if
start-stop-daemon
--start
--chuid
$USER
--background
--oknodo
--pidfile
$PIDFILE
--make-pidfile
--exec
$DAEMON
--
$CONFIG
;
then
$1
log_end_msg 0
;;
else
stop
)
log_end_msg 1
$1
fi
;;
;;
restart
)
stop
)
$1
# Stop the daemon.
;;
if
[
-e
$PIDFILE
]
;
then
status
)
status_of_proc
-p
$PIDFILE
$DAEMON
"Stoppping the
$NAME
process"
&&
status
=
"0"
||
status
=
"
$?
"
rh_status
if
[
"
$status
"
=
0
]
;
then
;;
start-stop-daemon
--stop
--retry
=
TERM/60/KILL/5
--quiet
--oknodo
--pidfile
$PIDFILE
*
)
/bin/rm
-rf
$PIDFILE
echo
$"Usage:
$0
{start|stop|status|restart}"
fi
exit
2
else
esac
log_daemon_msg
"
$NAME
process is not running"
exit
$?
log_end_msg 0
\ No newline at end of file
fi
;;
restart
)
# Restart the daemon.
$0
stop
&&
sleep
2
&&
$0
start
;;
status
)
# Check the status of the process.
if
[
-e
$PIDFILE
]
;
then
status_of_proc
-p
$PIDFILE
$DAEMON
"
$NAME
process"
&&
exit
0
||
exit
$?
else
log_daemon_msg
"
$NAME
Process is not running"
log_end_msg 0
fi
;;
*
)
# For invalid arguments, print the usage message.
echo
"Usage:
$0
{start|stop|restart|status}"
exit
2
;;
esac
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment