variksoo21

Untitled

Jul 17th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. SCREEN_SESSION="server"
  2.  
  3.  
  4. check_session () {
  5. screen -S "${SCREEN_SESSION}" -Q select . >/dev/null
  6. return $?
  7. }
  8.  
  9. start_session () {
  10. check_session && {
  11. echo "Server is already running!"
  12. return 1
  13. }
  14. screen -dmS "${SCREEN_SESSION}" "echo 5"
  15. }
  16.  
  17. attach_session () {
  18. check_session || {
  19. echo "Session is not running!"
  20. return 1
  21. }
  22. screen -S "${SCREEN_SESSION}" -x
  23. }
  24.  
  25. if ! check_session; then
  26. start_session
  27. else
  28. attach_session
  29. fi
Advertisement
Add Comment
Please, Sign In to add comment