Skip to content

Commit a35324b

Browse files
committed
Split startup into root and non-root parts.
1 parent 4397562 commit a35324b

File tree

3 files changed

+90
-49
lines changed

3 files changed

+90
-49
lines changed

startup/phone.sudoers

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
%wheel ALL= NOPASSWD: /sbin/shutdown /usr/sbin/iw /sbin/ifconfig /sbin/route /sbin/reboot /usr/sbin/alsactl /usr/share/unicsy/ofone/ofone /usr/bin/amixer
1+
%wheel ALL= NOPASSWD: /sbin/shutdown /usr/sbin/iw /sbin/ifconfig /sbin/route /sbin/reboot /usr/sbin/alsactl /usr/share/unicsy/ofone/ofone /usr/share/unicsy/startup/root_startup /usr/bin/amixer

startup/root_startup.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/python2
2+
3+
from __future__ import print_function
4+
5+
import sys
6+
sys.path += [ "/usr/share/unicsy/lib" ]
7+
8+
import time
9+
import os
10+
import hardware
11+
import watchdog
12+
13+
def sy(s):
14+
os.system(s)
15+
16+
class Startup:
17+
def __init__(m):
18+
m.wd = watchdog.StartupWatchdog()
19+
20+
def run(m):
21+
print("Unicsy/root starting up")
22+
23+
wd = m.wd
24+
debian = True
25+
26+
try:
27+
os.chdir('/my/tui/ofone')
28+
except:
29+
debian = False
30+
print("Not on debian")
31+
32+
# Disable yellow battery light:
33+
hardware.enable_access('/sys/class/power_supply/bq24150a-0/stat_pin_enable')
34+
sy('echo 0 > /sys/class/power_supply/bq24150a-0/stat_pin_enable')
35+
# Enable charger control from non-root
36+
hardware.enable_access('/sys/class/power_supply/bq24150a-0/current_limit')
37+
# Enable hardware control from non-root, for tefone etc.
38+
hardware.enable_access('/sys/class/leds/lp5523:*/brightness')
39+
hardware.enable_access('/sys/class/backlight/acx565akm/brightness')
40+
hardware.enable_access('/sys/power/state')
41+
# keyd needs /dev/input access
42+
hardware.enable_access('/dev/input/event6')
43+
hardware.enable_access('/dev/input/event5')
44+
hardware.enable_access('/dev/input/event1')
45+
hardware.enable_access('/dev/input/event0')
46+
# power management
47+
sy('sudo mount /dev/zero -t debugfs /sys/kernel/debug/')
48+
sy('sudo chmod 755 /sys/kernel/debug')
49+
hardware.enable_access('/sys/kernel/debug/pm_debug/enable_off_mode')
50+
# This allows us to configure network. It is also extremely bad idea
51+
hardware.enable_access('/etc/resolv.conf')
52+
53+
hardware.hw.startup()
54+
55+
s = Startup()
56+
s.run()
57+

startup/x_startup.py

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,71 +19,53 @@ def __init__(m):
1919

2020
def run(m):
2121
print("Unicsy starting up")
22-
os.system("""
23-
xinput --set-prop --type=float "TSC200X touchscreen" "Coordinate Transformation Matrix" 1.10 0.00 -0.05 0.00 1.18 -0.10 0.00 0.00 1.00
24-
xinput --set-prop --type=int "TSC200X touchscreen" "Evdev Axis Inversion" 0 1
25-
xinput --set-prop --type=float "TSC2005 touchscreen" "Coordinate Transformation Matrix" 1.10 0.00 -0.05 0.00 1.18 -0.10 0.00 0.00 1.00
26-
xinput --set-prop --type=int "TSC2005 touchscreen" "Evdev Axis Inversion" 0 1
27-
xbindkeys -f /my/xbindkeysrc
28-
# FIXME
29-
""")
3022

3123
wd = m.wd
32-
debian = 1
24+
debian = True
3325

3426
try:
3527
os.chdir('/my/tui/ofone')
3628
except:
37-
debian = 0
29+
debian = False
3830
print("Not on debian")
39-
sy('../vfone/win_lock startup &')
40-
wd.progress(1, "sound")
41-
sy('sudo ./ztime')
42-
sy('sudo alsactl restore -f audio/alsa.playback.loud')
43-
sy('mplayer /my/tui/ofone/audio/message.mp3 &')
4431

45-
#sy('sudo ./autosleep')
32+
if debian:
33+
sy('../vfone/win_lock startup &')
34+
wd.progress(1, "sound")
35+
sy('sudo ./ztime')
36+
sy('sudo alsactl restore -f audio/alsa.playback.loud')
37+
sy('mplayer /my/tui/ofone/audio/message.mp3 &')
38+
39+
os.system("""
40+
xinput --set-prop --type=float "TSC200X touchscreen" "Coordinate Transformation Matrix" 1.10 0.00 -0.05 0.00 1.18 -0.10 0.00 0.00 1.00
41+
xinput --set-prop --type=int "TSC200X touchscreen" "Evdev Axis Inversion" 0 1
42+
xinput --set-prop --type=float "TSC2005 touchscreen" "Coordinate Transformation Matrix" 1.10 0.00 -0.05 0.00 1.18 -0.10 0.00 0.00 1.00
43+
xinput --set-prop --type=int "TSC2005 touchscreen" "Evdev Axis Inversion" 0 1
44+
xbindkeys -f /my/xbindkeysrc
45+
# FIXME
46+
""")
4647

4748
wd.progress(10, "hardware")
48-
# Disable yellow battery light:
49-
hardware.enable_access('/sys/class/power_supply/bq24150a-0/stat_pin_enable')
50-
sy('echo 0 > /sys/class/power_supply/bq24150a-0/stat_pin_enable')
51-
# Enable charger control from non-root
52-
hardware.enable_access('/sys/class/power_supply/bq24150a-0/current_limit')
53-
# Enable hardware control from non-root, for tefone etc.
54-
hardware.enable_access('/sys/class/leds/lp5523:*/brightness')
55-
hardware.enable_access('/sys/class/backlight/acx565akm/brightness')
56-
hardware.enable_access('/sys/power/state')
57-
# keyd needs /dev/input access
58-
hardware.enable_access('/dev/input/event6')
59-
hardware.enable_access('/dev/input/event5')
60-
hardware.enable_access('/dev/input/event1')
61-
hardware.enable_access('/dev/input/event0')
62-
# power management
63-
sy('sudo mount /dev/zero -t debugfs /sys/kernel/debug/')
64-
sy('sudo chmod 755 /sys/kernel/debug')
65-
hardware.enable_access('/sys/kernel/debug/pm_debug/enable_off_mode')
66-
# This allows us to configure network. It is also extremely bad idea
67-
hardware.enable_access('/etc/resolv.conf')
68-
69-
hardware.hw.startup()
49+
p = "/usr/share/unicsy/"
7050

51+
sy("sudo "+p+"root_startup")
52+
7153
# Enable autosleep
7254
# instructions are at
7355
# http://lists.infradead.org/pipermail/linux-arm-kernel/2014-April/250019.html
7456

75-
wd.progress(15, "power management")
76-
sy('sudo ./run')
77-
time.sleep(2)
57+
if debian:
58+
wd.progress(15, "power management")
59+
sy('sudo ./run')
60+
time.sleep(2)
7861

79-
wd.progress(20, "screensaver")
80-
sy('xscreensaver &')
62+
wd.progress(20, "screensaver")
63+
sy('xscreensaver &')
8164

8265
try:
8366
os.chdir('/my/ofono/test')
8467
except:
8568
print("ofono unavailable")
86-
debian = 0
8769

8870
if debian:
8971
wd.progress(30, "modem enable")
@@ -103,20 +85,24 @@ def build_script(name, cmd):
10385
return build_command(name, 'bash -c "%s; xmessage %s failed; sleep 1h"' % (cmd, cmd))
10486

10587
wd.progress(40, "daemons")
106-
p = "/usr/share/unicsy/"
88+
10789
# FIXME: some daemons should run as root
10890
m.mate = True
10991
if m.mate:
11092
cmd = "mate-terminal "
11193
else:
11294
cmd = "xfce4-terminal "
11395

96+
pmos_sudo = ""
97+
if not debian:
98+
pmos_sudo = "sudo "
99+
114100
cmd += build_script('1_tefone', '/my/tui/ofone/tefone')
115101
cmd += build_script('2_battery', p+'monitor/batmond')
116102
cmd += build_script('3_monitor', p+'monitor/mond')
117103
if debian:
118104
cmd += build_script('4_keys', p+'hacks/keyd')
119-
cmd += build_script('5_ofone', p+'ofone/ofone')
105+
cmd += build_script('5_ofone', pmos_sudo+p+'ofone/ofone')
120106
if debian:
121107
cmd += build_script('6_cmtspeech', '/my/libcmtspeechdata/run')
122108
cmd += build_script('7_lockd', p+'hacks/lockd.py')
@@ -135,8 +121,6 @@ def build_script(name, cmd):
135121
# Allow win_lock to live for a while.
136122
time.sleep(120000)
137123

138-
139-
140124
s = Startup()
141125
s.run()
142126

0 commit comments

Comments
 (0)