-
Notifications
You must be signed in to change notification settings - Fork 2
/
sKit-tweaks
executable file
·178 lines (120 loc) · 3.49 KB
/
sKit-tweaks
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/sh
#
# soundcheck's tuning kit - pCP - sKit-tweaks
# activates advanced system configurations
# for RPi4 and related CM modules
#
# Latest Update: Aug-07-2021
#
#
# Copyright © 2021 - Klaus Schulz
# All rights reserved
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.
#
# If not, see http://www.gnu.org/licenses
#
########################################################################
VERSION=1.3
sKit_VERSION=1.5
fname="${0##*/}"
opts="$@"
###functions############################################################
out() {
echo -e "\tprogram aborted" >>$LOG
echo -e "\t${RED}ERROR: $@ ${NC}" >>$LOG
exit 1
}
license() {
echo "
soundcheck's tuning kit (${fname})
Copyright © 2021 - Klaus Schulz (aka soundcheck)
All rights reserved
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.
If not, see http://www.gnu.org/licenses
" >>$LOG
}
env_set() {
BOOT_DEV=/dev/mmcblk0p1
BOOT_MNT=/mnt/mmcblk0p1
ROOT_DEV=/dev/mmcblk0p2
ROOT_MNT=/mnt/mmcblk0p2
TCE="$ROOT_MNT/tce"
sKitbase=$TCE/sKit
LOGDIR=$sKitbase/log
LOG=$LOGDIR/$fname.log
TIMEOUT="180"
CPU_AFFINITY=0x6
}
set_log() {
echo >$LOG
}
check_pcp() {
if ! uname -a | grep -q -i pcp; then
out "No piCorePlayer system"
fi
}
check_custom_squeezelite() {
[[ ! -f /mnt/mmcblk0p2/tce/squeezelite-custom ]] && out "custom squeezelite installation missing"
}
set_sl_affinity() {
for i in $(ps -eLo tid,comm,command | grep squeezelite-custom | grep -v "output_alsa" | grep -v grep | awk '{print $1}'); do
sudo taskset -p $CPU_AFFINITY $i >>$LOG
done
}
stop_idlenet() {
ACTIF=$(route | grep '^default' | grep -o '[^ ]*$')
if [[ "$ACTIF" == "eth0" ]]; then
sudo ifconfig wlan0 down >>$LOG
elif [[ "$ACTIF" == "wlan0" ]]; then
sudo ifconfig eth0 down >>$LOG
fi
}
stop_procs() {
procs='httpd ssh udhcpc pcpmdnsd'
sleep $TIMEOUT
for i in $procs; do
sudo pkill -f $i >>$LOG
done
}
log_stat() {
ps -Leo rtprio,pri,psr,pid,tid,comm,cmd >>$LOG
ifconfig >>$LOG
}
clear_cache() {
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
}
#MAINMAIN##################################
check_pcp
env_set
set_log
check_custom_squeezelite
license
set_sl_affinity
stop_idlenet
stop_procs
log_stat
clear_cache
exit 0
###########################################