Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # NetworkManager: NetworkManager daemon
  4. #
  5. # description: This is a daemon for automatically switching network
  6. # connections to the best available connection.
  7. #
  8. # processnames: NetworkManager, wpa_supplicant
  9. # pidfiles: /var/run/NetworkManager.pid, /var/run/wpa_supplicant.pid
  10. #
  11. # This file has been modified for Slackware 12 compatibility, and
  12. # to include dbus service for wpa_supplicant for NetworkManager 0.7svn (stevek)
  13.  
  14. NETWORKMANAGER=/usr/sbin/NetworkManager
  15. WPA_SUPPLICANT=/usr/sbin/wpa_supplicant
  16.  
  17. # Make sure NetworkManager is executable
  18. [ -x $NETWORKMANAGER ] || exit 0
  19.  
  20. # We need /sbin/ip
  21. [ -x /sbin/ip ] || exit 0
  22.  
  23. # We need wpa_supplicant for dbus support
  24. [ -x $WPA_SUPPLICANT ] || exit 0
  25.  
  26. NM_PIDFILE=/var/run/NetworkManager.pid
  27.  
  28.  
  29. nm_start()
  30. {
  31. # Check for dbus
  32. if [ "`pgrep dbus-daemon`" = "" ]; then
  33. echo "D-BUS must be running to start NetworkManager"
  34. return ;
  35. fi
  36.  
  37. # Check for HAL
  38. if [ "`pgrep hald`" = "" ]; then
  39. echo "HAL must be running to start NetworkManager"
  40. return
  41. fi
  42.  
  43. # Make sure we aren't already running
  44.  
  45. if ps acx | grep -q NetworkManager ; then
  46. echo "NetworkManager already running."
  47. else
  48. echo "Starting NetworkManager daemon: $NETWORKMANAGER --pid-file $NM_PIDFILE"
  49. # Start up
  50. $NETWORKMANAGER --pid-file $NM_PIDFILE
  51. fi ;
  52.  
  53. }
  54.  
  55. nm_status()
  56. {
  57. if ps acx | grep -q NetworkManager ; then
  58. echo "NetworkManager running."
  59. fi;
  60.  
  61. }
  62.  
  63. nm_stop()
  64. {
  65. echo -en "Stopping NetworkManager: "
  66. local pidlist=`cat $NM_PIDFILE 2>/dev/null`
  67. if [ ! -z "$pidlist" ]; then
  68. kill $pidlist &>/dev/null
  69. rm -f $NM_PIDFILE &>/dev/null
  70. fi
  71. ## Be sure we're dead
  72. killall -q -15 NetworkManager
  73. echo "stopped";
  74.  
  75. echo -en "Stopping wpa_supplicant dbus services: "
  76. local pidlist=`cat $WPA_PIDFILE 2>/dev/null`
  77. if [ ! -z "$pidlist" ]; then
  78. kill $pidlist &>/dev/null
  79. rm -f $WPA_PIDFILE &>/dev/null
  80. fi
  81. ## Be sure we're dead
  82. killall -q -15 wpa_supplicant
  83. killall -q -15 nm-system-settings
  84. echo "stopped";
  85. }
  86.  
  87. nm_restart()
  88. {
  89. nm_stop
  90. nm_start
  91. }
  92.  
  93. case "$1" in
  94. 'start')
  95. nm_start
  96. ;;
  97. 'stop')
  98. nm_stop
  99. ;;
  100. 'restart')
  101. nm_restart
  102. ;;
  103. 'status')
  104. nm_status
  105. ;;
  106. *)
  107. echo "usage $0 start|stop|status|restart"
  108. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement