-
Notifications
You must be signed in to change notification settings - Fork 0
/
enableCameraModule
executable file
·64 lines (55 loc) · 1.36 KB
/
enableCameraModule
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
#!/bin/bash
# This code is directly copied from raspi-config
/show/description "Enable camera module"
if [[ $# -ne 0 ]] || [[ $1 == "--help" ]] || [[ $(id -u) -ne 0 ]];then
/show/messagebox "$0"
/show/info '[beta] [camera] [rpicam]'
/show/usageDescription "Enable camera module in /boot/config.txt"
/show/usage "$0"
else
CONFIG=/boot/config.txt
set_config_var() {
lua - "$1" "$2" "$3" <<EOF > "$3.bak"
local key=assert(arg[1])
local value=assert(arg[2])
local fn=assert(arg[3])
local file=assert(io.open(fn))
local made_change=false
for line in file:lines() do
if line:match("^#?%s*"..key.."=.*$") then
line=key.."="..value
made_change=true
end
print(line)
end
if not made_change then
print(key.."="..value)
end
EOF
mv "$3.bak" "$3"
}
get_config_var() {
lua - "$1" "$2" <<EOF
local key=assert(arg[1])
local fn=assert(arg[2])
local file=assert(io.open(fn))
for line in file:lines() do
local val = line:match("^#?%s*"..key.."=(.*)$")
if (val ~= nil) then
print(val)
break
end
end
EOF
}
/show/listecho "Modify $CONFIG" $OK
set_config_var start_x 1 $CONFIG
CUR_GPU_MEM=$(get_config_var gpu_mem $CONFIG)
if [ -z "$CUR_GPU_MEM" ] || [ "$CUR_GPU_MEM" -lt 128 ]; then
set_config_var gpu_mem 128 $CONFIG
fi
sed $CONFIG -i -e "s/^startx/#startx/"
sed $CONFIG -i -e "s/^fixup_file/#fixup_file/"
cat /boot/config.txt
/show/listecho "You need to reboot" $ERR
fi