Browse Source

Add zleeping from saturnin_zleep.sh

Alois Mahdal 10 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
     return $rv
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
 zleep() {
56
 zleep() {
49
     #
57
     #
50
     # Put the host on sleep
58
     # Put the host on sleep
64
     then
72
     then
65
         ZLEEP_ON_USER=$(mktemp)
73
         ZLEEP_ON_USER=$(mktemp)
66
         ZLEEP_ON_ROOT=$(mktemp -u)
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
             ZLEEP_ON_ROOT=$ZLEEP_ON_ROOT \
78
             ZLEEP_ON_ROOT=$ZLEEP_ON_ROOT \
70
             ZLEEP_ON_USER=$ZLEEP_ON_USER \
79
             ZLEEP_ON_USER=$ZLEEP_ON_USER \
80
+            PATH=$SUDO_PATH \
71
             saturnin iam zleeping &
81
             saturnin iam zleeping &
72
         wait_until -t 60 __zleep_sudo_part_started    # i.e. password prompt done
82
         wait_until -t 60 __zleep_sudo_part_started    # i.e. password prompt done
73
         __zleep_user_part
83
         __zleep_user_part

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

5
 ffoo import pretty
5
 ffoo import pretty
6
 ffoo import recon
6
 ffoo import recon
7
 
7
 
8
+ffoo import saturnin_zleep
9
+
8
 
10
 
9
 #
11
 #
10
 # self help
12
 # self help
25
     echo wfh
27
     echo wfh
26
     echo writing
28
     echo writing
27
     echo undocking
29
     echo undocking
30
+    echo zleeping
28
 }
31
 }
29
 
32
 
30
 usage() {
33
 usage() {
222
     saturnin conf -p iam.undocking.like | bash -
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
 cmd=$1
237
 cmd=$1
226
 
238
 
227
 test -n "$cmd" || usage
239
 test -n "$cmd" || usage