Skip to content

Commit

Permalink
Split startup into root and non-root parts.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelmachek committed Feb 7, 2018
1 parent 4397562 commit a35324b
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 49 deletions.
2 changes: 1 addition & 1 deletion startup/phone.sudoers
Original file line number Diff line number Diff line change
@@ -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
%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
57 changes: 57 additions & 0 deletions startup/root_startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/python2

from __future__ import print_function

import sys
sys.path += [ "/usr/share/unicsy/lib" ]

import time
import os
import hardware
import watchdog

def sy(s):
os.system(s)

class Startup:
def __init__(m):
m.wd = watchdog.StartupWatchdog()

def run(m):
print("Unicsy/root starting up")

wd = m.wd
debian = True

try:
os.chdir('/my/tui/ofone')
except:
debian = False
print("Not on debian")

# Disable yellow battery light:
hardware.enable_access('/sys/class/power_supply/bq24150a-0/stat_pin_enable')
sy('echo 0 > /sys/class/power_supply/bq24150a-0/stat_pin_enable')
# Enable charger control from non-root
hardware.enable_access('/sys/class/power_supply/bq24150a-0/current_limit')
# Enable hardware control from non-root, for tefone etc.
hardware.enable_access('/sys/class/leds/lp5523:*/brightness')
hardware.enable_access('/sys/class/backlight/acx565akm/brightness')
hardware.enable_access('/sys/power/state')
# keyd needs /dev/input access
hardware.enable_access('/dev/input/event6')
hardware.enable_access('/dev/input/event5')
hardware.enable_access('/dev/input/event1')
hardware.enable_access('/dev/input/event0')
# power management
sy('sudo mount /dev/zero -t debugfs /sys/kernel/debug/')
sy('sudo chmod 755 /sys/kernel/debug')
hardware.enable_access('/sys/kernel/debug/pm_debug/enable_off_mode')
# This allows us to configure network. It is also extremely bad idea
hardware.enable_access('/etc/resolv.conf')

hardware.hw.startup()

s = Startup()
s.run()

80 changes: 32 additions & 48 deletions startup/x_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,71 +19,53 @@ def __init__(m):

def run(m):
print("Unicsy starting up")
os.system("""
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
xinput --set-prop --type=int "TSC200X touchscreen" "Evdev Axis Inversion" 0 1
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
xinput --set-prop --type=int "TSC2005 touchscreen" "Evdev Axis Inversion" 0 1
xbindkeys -f /my/xbindkeysrc
# FIXME
""")

wd = m.wd
debian = 1
debian = True

try:
os.chdir('/my/tui/ofone')
except:
debian = 0
debian = False
print("Not on debian")
sy('../vfone/win_lock startup &')
wd.progress(1, "sound")
sy('sudo ./ztime')
sy('sudo alsactl restore -f audio/alsa.playback.loud')
sy('mplayer /my/tui/ofone/audio/message.mp3 &')

#sy('sudo ./autosleep')
if debian:
sy('../vfone/win_lock startup &')
wd.progress(1, "sound")
sy('sudo ./ztime')
sy('sudo alsactl restore -f audio/alsa.playback.loud')
sy('mplayer /my/tui/ofone/audio/message.mp3 &')

os.system("""
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
xinput --set-prop --type=int "TSC200X touchscreen" "Evdev Axis Inversion" 0 1
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
xinput --set-prop --type=int "TSC2005 touchscreen" "Evdev Axis Inversion" 0 1
xbindkeys -f /my/xbindkeysrc
# FIXME
""")

wd.progress(10, "hardware")
# Disable yellow battery light:
hardware.enable_access('/sys/class/power_supply/bq24150a-0/stat_pin_enable')
sy('echo 0 > /sys/class/power_supply/bq24150a-0/stat_pin_enable')
# Enable charger control from non-root
hardware.enable_access('/sys/class/power_supply/bq24150a-0/current_limit')
# Enable hardware control from non-root, for tefone etc.
hardware.enable_access('/sys/class/leds/lp5523:*/brightness')
hardware.enable_access('/sys/class/backlight/acx565akm/brightness')
hardware.enable_access('/sys/power/state')
# keyd needs /dev/input access
hardware.enable_access('/dev/input/event6')
hardware.enable_access('/dev/input/event5')
hardware.enable_access('/dev/input/event1')
hardware.enable_access('/dev/input/event0')
# power management
sy('sudo mount /dev/zero -t debugfs /sys/kernel/debug/')
sy('sudo chmod 755 /sys/kernel/debug')
hardware.enable_access('/sys/kernel/debug/pm_debug/enable_off_mode')
# This allows us to configure network. It is also extremely bad idea
hardware.enable_access('/etc/resolv.conf')

hardware.hw.startup()
p = "/usr/share/unicsy/"

sy("sudo "+p+"root_startup")

# Enable autosleep
# instructions are at
# http://lists.infradead.org/pipermail/linux-arm-kernel/2014-April/250019.html

wd.progress(15, "power management")
sy('sudo ./run')
time.sleep(2)
if debian:
wd.progress(15, "power management")
sy('sudo ./run')
time.sleep(2)

wd.progress(20, "screensaver")
sy('xscreensaver &')
wd.progress(20, "screensaver")
sy('xscreensaver &')

try:
os.chdir('/my/ofono/test')
except:
print("ofono unavailable")
debian = 0

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

wd.progress(40, "daemons")
p = "/usr/share/unicsy/"

# FIXME: some daemons should run as root
m.mate = True
if m.mate:
cmd = "mate-terminal "
else:
cmd = "xfce4-terminal "

pmos_sudo = ""
if not debian:
pmos_sudo = "sudo "

cmd += build_script('1_tefone', '/my/tui/ofone/tefone')
cmd += build_script('2_battery', p+'monitor/batmond')
cmd += build_script('3_monitor', p+'monitor/mond')
if debian:
cmd += build_script('4_keys', p+'hacks/keyd')
cmd += build_script('5_ofone', p+'ofone/ofone')
cmd += build_script('5_ofone', pmos_sudo+p+'ofone/ofone')
if debian:
cmd += build_script('6_cmtspeech', '/my/libcmtspeechdata/run')
cmd += build_script('7_lockd', p+'hacks/lockd.py')
Expand All @@ -135,8 +121,6 @@ def build_script(name, cmd):
# Allow win_lock to live for a while.
time.sleep(120000)



s = Startup()
s.run()

Expand Down

0 comments on commit a35324b

Please sign in to comment.