-
Notifications
You must be signed in to change notification settings - Fork 1
/
fury
executable file
·98 lines (82 loc) · 2.62 KB
/
fury
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /usr/bin/env python3
# -*- coding: UTF-8 -*-
# Powerful client of furyTerminal
import os
import sys
def sh(command):
os.system(command)
def runServer():
sh('''
python ./manage.py runserver 0:8000 >log/server.log 2>&1 &
''')
def testModule():
pass
def makeMigrationMigrate():
sh('''
python ./manage.py makemigrations
python ./manage.py migrate
''')
def install():
"""
install necessary packages
"""
sh('''
sudo apt install bc -y
sudo apt install python3 python3-dev -y
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install django
pip3 install python-can
pip3 install mysqlclient
sudo apt install mariadb-server mariadb-client -y
sudo echo -e "# enable can bus
\rdtparam=spi=on
\rdtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25,spimaxfrequency=1000000" >> /boot/config.txt
''')
def config():
"""
setup autorun configurations
"""
# copy web page auto start config file
if not os.path.exists(os.path.expanduser('~/.config/autostart/')):
os.mkdir(os.path.expanduser('~/.config/autostart/'))
sh('cp -f config/oncar.desktop ~/.config/autostart/')
# config startup cmdline
with open('/boot/cmdline.txt', 'r') as f:
cmdline = f.read().strip().split()
cmd_config = [
'logo.nologo', # disable the three respberry at left up corner when booting
'splash', # enable splash screen
'plymouth.ignore-serial-consoles', # cover consoles by plymouth
'loglevel=3' # output less lines
'quiet', # disable lines
]
with open('/boot/cmdline.txt', 'a+') as f:
for item in cmd_config:
if item not in cmdline:
f.write(' ' + item)
sh('''
# configure services
cp -f config/fury.png ~/Pictures/
sudo cp -f config/splashScreen.service /etc/systemd/system/
sudo cp -f config/furyTerminal.service /etc/systemd/system/
sudo systemctl enable splashScreen
sudo systemctl enable furyTerminal
# disable color test
sudo sed -ir "s/disable_splash=1/disable_splash=0/g" /boot/config.txt
# set plymouth theme
sudo plymouth-set-default-theme spinner -R
''')
command = {
'default': runServer,
'r': runServer,
't': testModule,
'm': makeMigrationMigrate,
'install': install,
'config': config,
}
# change cwd first
os.chdir(sys.path[0])
main = command[sys.argv[1] if len(sys.argv) > 1 else 'default']
main()