Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SCREEN_SESSION="server"
- check_session () {
- screen -S "${SCREEN_SESSION}" -Q select . >/dev/null
- return $?
- }
- start_session () {
- check_session && {
- echo "Server is already running!"
- return 1
- }
- screen -dmS "${SCREEN_SESSION}" "echo 5"
- }
- attach_session () {
- check_session || {
- echo "Session is not running!"
- return 1
- }
- screen -S "${SCREEN_SESSION}" -x
- }
- if ! check_session; then
- start_session
- else
- attach_session
- fi
Advertisement
Add Comment
Please, Sign In to add comment