-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_aliases
452 lines (417 loc) · 12.1 KB
/
bash_aliases
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
alias ll='ls -alh'
alias r-fw='systemctl reboot --firmware-setup'
alias pts='phoronix'
apt_command() {
if command -v apt-proxy &>/dev/null; then
apt-proxy "$@"
else
sudo apt "$@"
fi
}
mkcd ()
{
mkdir -p -- "$1" && cd -P -- "$1"
}
full-upgrade ()
{
path_to_add="$HOME/.local/bin"
if [ $(echo $PATH | grep -c $path_to_add) -eq 0 ]; then
echo "$path_to_add is not in PATH"
if [ $(grep -c "$path_to_add" $HOME/.bashrc) -eq 0 ]; then
echo PATH=$path_to_add:$PATH >> $HOME/.bashrc
fi
if [ -e .zshrc ]; then
if [ $(grep -c "$path_to_add" $HOME/.zshrc) -eq 0 ]; then
echo PATH=$path_to_add:$PATH >> $HOME/.zshrc
fi
fi
PATH=$path_to_add:$PATH
fi
until apt_command update
do
sleep 1
done
apt_command full-upgrade -y --allow-downgrades
apt_command autoremove -y
./check-needrestart.sh
if [ $? -gt 0 ]; then
systemctl reboot -i
fi
}
speed-test ()
{
RESPONSE=$(curl -I -s --connect-timeout 10 -o /dev/null -w "%{http_code}" "http://10.17.89.69:5000/download/llvm-project-main.zip")
URL="https://speed.cloudflare.com"
if [ "$RESPONSE" -eq 200 ]; then
URL="http://10.17.89.69:3000?Run"
fi
firefox $URL &>/dev/null &
}
cpuperf ()
{
./install.sh linux-tools-common linux-tools-generic
if [[ "$(cat /etc/os-release)" == *"Ubuntu"* ]];
then
./install.sh linux-tools-$(uname -r)
fi
sudo cpupower frequency-set -g performance
}
phoronix ()
{
./install.sh git php-cli php-xml
if ! command -v phoronix-test-suite &>/dev/null
then
pushd ~/Documents
git clone https://github.com/phoronix-test-suite/phoronix-test-suite.git
pushd phoronix-test-suite
sudo bash install-sh
popd
popd
phoronix-test-suite --help &>/dev/null
if [ -d ~/work-scripts ];
then
pushd ~/work-scripts
cp -Rvf phoronix/compress-pbzip2-1.7.0 ~/.phoronix-test-suite/test-profiles/local/
cp -Rvf phoronix/batman-knight-1.1.0 ~/.phoronix-test-suite/test-profiles/local/
cp -Rvf phoronix/batman-origins-1.6.2 ~/.phoronix-test-suite/test-profiles/local/
cp -Rvf phoronix/cyberpunk2077-1.0.2 ~/.phoronix-test-suite/test-profiles/local/
cp -Rvf phoronix/l4d2-1.0.2 ~/.phoronix-test-suite/test-profiles/local/
cp -Rvf phoronix/hitman3-1.0.2 ~/.phoronix-test-suite/test-profiles/local/
cp -Rvf phoronix/fio-custom ~/.phoronix-test-suite/test-suites/local/
cp -Rvf phoronix/cpu-medium ~/.phoronix-test-suite/test-suites/local/
cp -Rvf phoronix/some-games ~/.phoronix-test-suite/test-suites/local/
cp -Rvf phoronix/workstation-gpus ~/.phoronix-test-suite/test-suites/local/
popd
fi
fi
gsettings set org.gnome.desktop.session idle-delay 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type "nothing"
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type "nothing"
phoronix-test-suite $@
}
pts-cpu ()
{
PTS_TEST='cpu-medium'
if [ $# -gt 0 ]; then
PTS_TEST=$1
fi
./install.sh libelf-dev texinfo
sudo sh -c 'echo 1 > /proc/sys/kernel/perf_event_paranoid'
cpuperf
export TEST_TIMEOUT_AFTER=30
export WATCHDOG_SENSOR=cpu.temp
export WATCHDOG_SENSOR_THRESHOLD=90
export LINUX_PERF="power/energy-cores/,power/energy-pkg/"
export MONITOR=cpu.freq,cpu.temp,cpu.power,cpu.usage
export PTS_MODULES=system_monitor,linux_perf,test_timeout,watchdog
pts benchmark $PTS_TEST
}
pts-unigine ()
{
cpuperf
export TEST_TIMEOUT_AFTER=auto
export MONITOR=gpu.freq,gpu.temp,gpu.power,gpu.usage,gpu.memory-usage,gpu.fan-speed
export PTS_MODULES=system_monitor,test_timeout
pts benchmark unigine
}
pts-gpu ()
{
cpuperf
export TEST_TIMEOUT_AFTER=60
export MONITOR=gpu.freq,gpu.temp,gpu.power,gpu.usage,gpu.memory-usage,gpu.fan-speed
export PTS_MODULES=system_monitor,test_timeout
pts benchmark $1
}
pts-fio ()
{
cpuperf
export TEST_TIMEOUT_AFTER=auto
export MONITOR=hdd.read-speed,hdd.write-speed,hdd.temp
export WATCHDOG_SENSOR=hdd.temp
export WATCHDOG_SENSOR_THRESHOLD=75
export PTS_MODULES=system_monitor,watchdog,test_timeout
pts benchmark fio-custom
}
fah ()
{
if [ -e temp ];
then
rm -rvf temp
fi
if [ ! -e fahclient_7.4.4_amd64.deb ];
then
wget https://download.foldingathome.org/releases/public/release/fahclient/debian-testing-64bit/v7.4/fahclient_7.4.4_amd64.deb -O temp
mv temp fahclient_7.4.4_amd64.deb
fi
sudo dpkg -i --force-depends fahclient_7.4.4_amd64.deb
reboot
}
r-fah ()
{
sudo dpkg -P fahclient
reboot
}
pop-get ()
{
if [ ! -d ~/pop ];
then
./install.sh curl git
pushd ~/
git clone https://github.com/pop-os/pop.git
popd
fi
}
pop-apt ()
{
pop-get
~/pop/scripts/apt add $@
}
pop-remote ()
{
pop-get
~/pop/scripts/apt remote
}
pop-local ()
{
pop-get
~/pop/scripts/apt local
}
pop-remove ()
{
pop-get
~/pop/scripts/apt remove $@
}
gfp ()
{
git fetch --all
git pull --rebase
}
gfpr ()
{
git reset --hard HEAD
git restore .
git fetch --all
git pull --rebase
}
gfps ()
{
git stash
git reset --hard HEAD
git restore .
git fetch --all
git pull --rebase
git stash pop
}
mst ()
{
if [ ! -e /tmp/count ];
then
echo "1" > /tmp/count
echo "Suspend Number: 1"
else
scount=$(cat /tmp/count)
scount=$((scount + 1))
echo "Suspend number: $scount"
if [ $scount -lt 20 ];
then
echo $scount > /tmp/count
else
rm -f /tmp/count
fi
fi
systemctl suspend
}
drain-bat ()
{
SMART_PLUG=0
if [ $# -gt 0 ];
then
SMART_PLUG=1
HS100_ARGS=" -i $1"
fi
./install.sh stress-ng xdotool
if [ -d /sys/class/power_supply/BAT0 ];
then
STATUS=$(cat /sys/class/power_supply/BAT0/status)
if [ $SMART_PLUG -eq 1 ] && [ "$STATUS" != "Discharging" ];
then
if [ ! -d hs100 ];
then
git clone https://github.com/branning/hs100.git
fi
./hs100/hs100.sh${HS100_ARGS} off
sleep 15
fi
LAST_CHARGE=0
clear
start_time=$(date +%s)
while true;
do
cur_time=$(date +%s)
duration=$(($cur_time-$start_time))
if [ $duration -ge 280 ]
then
start_time=$(date +%s)
# Get the current mouse position
eval $(xdotool getmouselocation --shell)
# Move the mouse
xdotool mousemove --sync $((X+1)) $((Y+1))
xdotool mousemove --sync $X $Y
fi
STATUS=$(cat /sys/class/power_supply/BAT0/status)
CHARGE=$(cat /sys/class/power_supply/BAT0/capacity)
if [ "$STATUS" = "Discharging" ] && ! pgrep stress-ng &>/dev/null
then
$(bash ./terminal.sh --name=stress-ng --title=stress-ng) bash -c "stress-ng -c 0 -m 0"
fi
if [ $LAST_CHARGE -ne $CHARGE ];
then
LAST_CHARGE=$CHARGE
echo $CHARGE
fi
if [ $SMART_PLUG -eq 1 ] && [ $CHARGE -le 20 ];
then
./hs100/hs100.sh${HS100_ARGS} on
fi
if [ "$STATUS" != 'Discharging' ] || [ $CHARGE -le 20 ];
then
pkill stress-ng
fi
if [ $CHARGE -eq 100 ]
then
break
fi
sleep 1
done
fi
}
mem-speed ()
{
sudo dmidecode --type 17 | grep -i speed
}
pang12-stress ()
{
gsettings set org.gnome.desktop.session idle-delay 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type "nothing"
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type "nothing"
./install.sh stress-ng glmark2
$(bash ./terminal --name=stress-ng --title=stress-ng) bash -c "while true; do stress-ng -c 0 -m 0 --vm-bytes 25G; done"
$(bash ./terminal --name=glmark2 --title=glmark2) bash -c "glmark2 --run-forever"
$(bash ./terminal --name=journalctl --title=journalctl) bash -c "sudo journalctl -f | grep mce"
echo "" >> timestamp.txt
echo "new test run" >> timestamp.txt
while true
do
date >> timestamp.txt
sleep 60
date
done
}
build-stress ()
{
gsettings set org.gnome.desktop.session idle-delay 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type "nothing"
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type "nothing"
./install.sh curl build-essential libncurses5-dev fakeroot xz-utils libelf-dev bison flex dwarves unzip libssl-dev
pushd build
sudo rm -rvf linux*
if [ ! -e master.zip ];
then
wget https://github.com/pop-os/linux/archive/refs/heads/master.zip
fi
unzip -q master.zip linux-master/* -d temp
mkdir linux
mv temp/linux-master/* linux/
rm -rvf temp
if [ ! -d firmware-open ]; then
git clone https://github.com/system76/firmware-open.git
fi
pushd firmware-open
git reset --hard HEAD
git fetch --all
git pull --rebase
git submodule update --init --recursive --checkout
bash scripts/install-deps.sh
. edk2/edksetup.sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
chmod +x rustup.sh
bash rustup.sh -y --default-toolchain=nightly
source "$HOME/.cargo/env"
popd
pushd linux
make mrproper
git reset --hard HEAD
git restore .
make ARCH=x86_64 allmodconfig
if [ -e linux.orig ];
then
rm -rf linux.orig
fi
make -j`nproc` ARCH=x86_64 2> errors.log
popd
pushd firmware-open
bash scripts/build.sh oryp10
popd
popd
}
kdiskmark ()
{
if ! command -v flatpak &>/dev/null
then
./install.sh flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
fi
if [ ! -d "${HOME}/.local/share/flatpak/app/io.github.jonmagon.kdiskmark" ];
then
flatpak install -y flathub io.github.jonmagon.kdiskmark
fi
/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=kdiskmark io.github.jonmagon.kdiskmark
}
soundrec ()
{
if ! command -v flatpak &>/dev/null
then
./install.sh flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
fi
if [ ! -d "${HOME}/.local/share/flatpak/app/org.gnome.SoundRecorder" ];
then
flatpak install -y flathub org.gnome.SoundRecorder
fi
/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=gnome-sound-recorder org.gnome.SoundRecorder
}
kvmtpm ()
{
KVM="False"
TPM="False"
if [ -e /dev/kvm ];
then
KVM="True"
fi
if [ -d /sys/class/tpm/tpm0 ];
then
TPM="True"
fi
echo "KVM: ${KVM}"
echo "TPM: ${TPM}"
}
dmi ()
{
sudo echo "BIOS Information"
sudo dmidecode --type 0 | grep -e Vendor -e Version -e Date
echo "System Information"
sudo dmidecode --type 1 | grep -e Manufacturer -e 'Product Name' -e Version
echo "Base Board Information"
sudo dmidecode --type 2 | grep -e Manufacturer -e 'Product Name' -e Version
echo "Chassis Information"
sudo dmidecode --type 3 | grep -e Manufacturer -e Type -e Version
}
check_pkfail ()
{
./install.sh efitools
if [ $(efi-readvar -v PK | grep -c "DO NOT TRUST\|DO NOT SHIP") -gt 0 ]; then
echo "Vulnerable to PKFail, needs patching."
else
echo "PKFail not found."
fi
}