Browse Source

Add zleeping from saturnin_zleep.sh

Alois Mahdal 9 years ago
parent
commit
a8a805ec43
2 changed files with 24 additions and 2 deletions
  1. 12
    2
      src/ffoo/saturnin_zleep.sh
  2. 12
    0
      src/libexec/saturnin-iam

+ 12
- 2
src/ffoo/saturnin_zleep.sh View File

@@ -45,6 +45,14 @@ __zleep_user_part_done() {
45 45
     return $rv
46 46
 }
47 47
 
48
+__zleep_min_path() {
49
+    echo -n $(sudo env | grep ^PATH)
50
+    echo -n :
51
+    echo -n $(dirname $(which ffoom))
52
+    echo -n :
53
+    echo -n $(dirname $(which saturnin))
54
+}
55
+
48 56
 zleep() {
49 57
     #
50 58
     # Put the host on sleep
@@ -64,10 +72,12 @@ zleep() {
64 72
     then
65 73
         ZLEEP_ON_USER=$(mktemp)
66 74
         ZLEEP_ON_ROOT=$(mktemp -u)
67
-        debug -v ZLEEP_ON_USER ZLEEP_ON_ROOT
68
-        sudo \
75
+        SUDO_PATH=$(__zleep_min_path)   # needed while bins are still under local
76
+        debug -v ZLEEP_ON_USER ZLEEP_ON_ROOT SUDO_PATH
77
+        sudo env \
69 78
             ZLEEP_ON_ROOT=$ZLEEP_ON_ROOT \
70 79
             ZLEEP_ON_USER=$ZLEEP_ON_USER \
80
+            PATH=$SUDO_PATH \
71 81
             saturnin iam zleeping &
72 82
         wait_until -t 60 __zleep_sudo_part_started    # i.e. password prompt done
73 83
         __zleep_user_part

+ 12
- 0
src/libexec/saturnin-iam View File

@@ -5,6 +5,8 @@
5 5
 ffoo import pretty
6 6
 ffoo import recon
7 7
 
8
+ffoo import saturnin_zleep
9
+
8 10
 
9 11
 #
10 12
 # self help
@@ -25,6 +27,7 @@ available_commands() {
25 27
     echo wfh
26 28
     echo writing
27 29
     echo undocking
30
+    echo zleeping
28 31
 }
29 32
 
30 33
 usage() {
@@ -222,6 +225,15 @@ i_am_undocking() {
222 225
     saturnin conf -p iam.undocking.like | bash -
223 226
 }
224 227
 
228
+i_am_zleeping() {
229
+    #
230
+    # i.e. hibernated
231
+    #
232
+    set_status "zleeping"
233
+    zleep
234
+    i_am_back
235
+}
236
+
225 237
 cmd=$1
226 238
 
227 239
 test -n "$cmd" || usage