Skip to content

Commit b826b3d

Browse files
committed
Merge branch 'master' of github.com:sroller/scripts
2 parents 7e1086b + d163e78 commit b826b3d

15 files changed

+228
-92
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ ffprobe
99
x264
1010
lein
1111
linux-install*
12+
yt-dlp
13+
vmaf

Diff for: build_ffmpeg_from_scratch

+38-11
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,29 @@ sudo apt-get update -qq && sudo apt-get -y install \
3333
wget \
3434
yasm \
3535
zlib1g-dev \
36-
nasm libnuma-dev
36+
nasm libnuma-dev libnuma1
3737

3838
# libfdk-aac-dev libopus-dev libsvtav1-dev libsvtav1enc-dev libsvtav1dec-dev libdav1d-dev libunistring-dev python3-pip
39-
39+
40+
cd ~
41+
rm -rf ffmpeg_source
42+
rm -rf ffmpeg_build
4043
mkdir -p ~/ffmpeg_sources ~/bin
4144

45+
# for Nvidia support
46+
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
47+
cd nv-codec-headers && sudo make install && cd -
48+
49+
# netflix
50+
cd ~/ffmpeg_sources
51+
# wget https://github.com/Netflix/vmaf/archive/v3.0.0.tar.gz
52+
if [ $(gh release list -L 1 -R Netflix/vmaf | awk '{print $1}') != 'v3.0.0' ]
53+
then
54+
echo New release of Netflix/vmaf available!
55+
echo change script $0
56+
exit
57+
fi
58+
4259
# install x264 support
4360
cd ~/ffmpeg_sources
4461
git -C x264 pull 2> /dev/null || git clone --depth 1 https://code.videolan.org/videolan/x264.git
@@ -104,10 +121,7 @@ make
104121
make install
105122

106123

107-
# netflix
108-
cd ~/ffmpeg_sources
109-
wget https://github.com/Netflix/vmaf/archive/v3.0.0.tar.gz
110-
tar xvf v3.0.0.tar.gz
124+
tar xvf ~/share/Netflix/vmaf/archive/v3.0.0.tar.gz
111125
mkdir -p vmaf-3.0.0/libvmaf/build
112126
cd vmaf-3.0.0/libvmaf/build
113127
meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=static .. --prefix "$HOME/ffmpeg_build" --bindir="$HOME/bin" --libdir="$HOME/ffmpeg_build/lib"
@@ -123,11 +137,14 @@ PATH="$HOME/bin:$PATH" make
123137
make install
124138

125139
cd ~/ffmpeg_sources
126-
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
127-
tar xjvf ffmpeg-snapshot.tar.bz2
128-
git clone https://git.ffmpeg.org/ffmpeg.git
129-
cd ffmpeg
140+
git -C ffmpeg pull || git clone https://git.ffmpeg.org/ffmpeg.git
141+
# wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
142+
# tar xjvf ffmpeg-snapshot.tar.bz2
143+
# cd ffmpeg
144+
# git pull
130145

146+
cd ffmpeg
147+
pwd
131148
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
132149
--prefix="$HOME/ffmpeg_build" \
133150
--pkg-config-flags="--static" \
@@ -150,7 +167,17 @@ PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./conf
150167
--enable-libvpx \
151168
--enable-libx264 \
152169
--enable-libx265 \
153-
--enable-nonfree && \
170+
--enable-nonfree \
171+
--enable-cuda-nvcc \
172+
--enable-cuda-nvcc \
173+
--enable-libnpp \
174+
--extra-cflags=-I/usr/local/cuda/include \
175+
--extra-ldflags=-L/usr/local/cuda/lib64 \
176+
--enable-nvenc \
177+
--enable-nvdec \
178+
--enable-cuvid \
179+
--enable-gpl \
180+
--enable-version3 && \
154181
PATH="$HOME/bin:$PATH" make && \
155182
make install && \
156183
hash -r

Diff for: create_pdf.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def create_tex(src_dir)
2929
def create_pdf(tex_file)
3030
STDERR.puts "output=#{tex_file}"
3131
exit_code = %x( pdflatex -interaction=batchmode #{tex_file} 2>&1 )
32-
# STDERR.puts "exit code #{exit_code}"
32+
STDERR.puts "exit code #{exit_code}"
3333
end
3434

3535
def clean_up(work_dir)
36-
# STDERR.puts "cleanup #{work_dir}"
36+
STDERR.puts "cleanup #{work_dir}"
3737
Dir.chdir work_dir
3838
Dir['*.log'].each {|f| File.delete f}
3939
Dir['*.aux'].each {|f| File.delete f}

Diff for: health-check

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Check disk space
4+
df -h / | awk '{ print $5 " " $1 }' | grep -v Use | while read output;
5+
do
6+
echo "Disk Space Check: $output"
7+
done
8+
9+
# Check memory usage
10+
free -m | grep Mem | awk '{print "Memory Usage: "$3"/"$2" MB"}'
11+
12+
# Check CPU load
13+
uptime | awk '{print "CPU Load Average (15 min): "$12}'

Diff for: install-on-all

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
#
3+
# installs software on all machines
4+
5+
usage () { echo "$0 usage: " && grep " .)\ #" $0; exit 0; }
6+
while getopts "a:c:h" arg; do
7+
case $arg in
8+
a) # possible action: install|remove
9+
echo "action: ${OPTARG}"
10+
ACTION="install"
11+
;;
12+
c) # name of package
13+
echo "command: ${OPTARG}"
14+
PACKAGE="${OPTARG}"
15+
;;
16+
h | *)
17+
usage
18+
exit 0
19+
;;
20+
esac
21+
done
22+
23+
for node in europa.local io.local ganymede.local callisto.local titan.local phobos.local [email protected]
24+
do
25+
echo '************************************'
26+
echo " $node"
27+
echo '************************************'
28+
echo connecting ...
29+
ssh $node "uname -a ; sudo apt-get -y ${ACTION} ${PACKAGE}"
30+
echo '************************************'
31+
echo " $node done"
32+
echo '************************************'
33+
done
34+

Diff for: ip_to_host

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# set -x
4+
# Get the IP address from the first argument
5+
ip_address="$1"
6+
7+
# Use the 'host' command to resolve the IP address to a hostname
8+
hostname=$(host "$ip_address" | head -n 1 | awk '/domain name pointer/ {print $5}' | sed 's/\.$//')
9+
10+
# Check if the 'host' command was successful
11+
if [ -n "$hostname" ]; then
12+
# echo "The hostname for IP address $ip_address is $hostname"
13+
echo $hostname
14+
else
15+
# echo "Failed to resolve hostname for IP address $ip_address"
16+
echo $ip_address
17+
fi

Diff for: mkmov

+9-4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ function help {
3939
-2 enables two-pass mode
4040
-p PRESET (default:$PRESET) only used for x264
4141
42+
start with
43+
44+
DEBUG=1 $(basename $0) ...
45+
46+
to enable debugging
47+
4248
EOH
4349
exit
4450
}
@@ -90,11 +96,10 @@ fi
9096

9197

9298
if [ "$CODEC" != "iphone" ]; then
93-
if [ -f tl000001.jpg ]; then
94-
FDATE=$(stat -c"%y" tl000001.jpg 2> /dev/null |cut -b1-10)
95-
DATUM=$(stat -c"%y" tl000001.jpg 2> /dev/null |cut -b1-10|perl -npe "s/(\d+)\-(\d+)\-(\d+)/\3.\2.\1/")
99+
if true; then
100+
DATUM=$(ls -1 *.jpg | head -n 1 | xargs stat -c"%y" | cut -b1-10)
96101
else
97-
echo "couldn't find tl000001.jpg"
102+
echo "couldn't find jpg file"
98103
echo "wrong directory?"
99104
exit
100105
fi

Diff for: move-to-hennecke

-21
This file was deleted.

Diff for: network_monitor2

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
TEKSAVVY=mysavvy.teksavvy.com
4+
LOG=$HOME/var/log/$(date +%Y%m%d)-network_monitor2.log
5+
6+
echo "start at $(date)"
7+
echo "start at $(date)" >> $LOG
8+
echo "timestamp,seconds" >> $LOG
9+
10+
while true
11+
do
12+
if ping -c 1 -W 1 $TEKSAVVY &> /dev/null; then
13+
echo -en "$(date +%H:%M:%S)\r"
14+
else
15+
# Capture outage start time FIRST
16+
START_TIME=$(date +%s)
17+
RC=$?
18+
echo
19+
echo "$(date +%Y%m%d-%H%M%S): $(basename $0): ping to $TEKSAVVY failed with rc=$RC"
20+
# echo "$(date +%Y%m%d-%H%M%S): $(basename $0): ping to $TEKSAVVY failed with rc=$RC" >> $LOG
21+
22+
# Router check (secondary diagnostic)
23+
curl --head -s http://192.168.1.1/webpages/login.html > /dev/null
24+
if [ $? -ne 0 ]; then
25+
echo "$(date +%Y%m%d-%H%M%S): $(basename $0): curl to router NOT ok"
26+
fi
27+
28+
# Continuous retry loop
29+
while : ; do
30+
if ping -c 1 -W 1 $TEKSAVVY &> /dev/null; then
31+
END_TIME=$(date +%s)
32+
OUTAGE_DURATION=$((END_TIME - START_TIME))
33+
if [ $OUTAGE_DURATION -gt 1 ]; then
34+
echo "$(date +%Y%m%d-%H%M%S): Connection restored after ${OUTAGE_DURATION} seconds"
35+
echo "$(date +%Y%m%d-%H%M%S),${OUTAGE_DURATION}" >> $LOG
36+
fi
37+
break
38+
fi
39+
sleep 1
40+
done
41+
fi
42+
sleep 7
43+
done

Diff for: path

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo $PATH | tr ":" "\n"

Diff for: process_speedtest

-48
This file was deleted.

Diff for: speedtest

-5
This file was deleted.

Diff for: speedtest.py

-1
This file was deleted.

Diff for: tail_httpd_logs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
sudo tail -n 20 -f /var/log/nginx/access.log /var/log/nginx/error.log | awk '
4+
{
5+
# print ">> "$0 " <<"
6+
# replace ip number with hostname
7+
if ($0 !~ /\/var\/log/) {
8+
if ($1 != "") {
9+
cmd="~/bin/ip_to_host " $1
10+
cmd | getline name
11+
close(cmd)
12+
$1 = name
13+
}
14+
}
15+
16+
if ($9 ~ /^4[0-9]{2}$/) {
17+
print "\033[0;31m" $0 "\033[0m"
18+
} else {
19+
print $0
20+
}
21+
}'

Diff for: update-all-machines

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# tmux new -d -s "update-all"
4+
5+
MACHINES="europa.local io.local ganymede.local callisto.local titan.local phobos.local pi-hole.local"
6+
DEAD=0
7+
8+
# all machines alive?
9+
echo "check whether all systems are alive"
10+
for node in $MACHINES
11+
do
12+
if ping -W 1 -c 1 $node > /dev/null
13+
then
14+
echo "$node is alive"
15+
else
16+
DEAD=1
17+
fi
18+
done
19+
20+
if [ "$DEAD" == "1" ]
21+
then
22+
read -p "Do you want to continue anyway? (y/n)" yn
23+
case $yn in
24+
[Yy]* ) echo "Let's go then"
25+
break;;
26+
[Nn]* ) echo "Go fix your stuff and try again"
27+
exit;;
28+
esac
29+
fi
30+
31+
for node in $MACHINES
32+
do
33+
echo -ne "\033]0;updating $node\007"
34+
echo '************************************'
35+
echo " $node"
36+
echo '************************************'
37+
echo connecting ...
38+
ssh $node "uname -a ; sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get -y dist-upgrade ; sudo apt-get -y autoremove"
39+
echo '************************************'
40+
echo " $node done"
41+
echo '************************************'
42+
done
43+
44+
echo '************************************'
45+
echo " pihole -up"
46+
echo '************************************'
47+
ssh [email protected] "sudo pihole -up"

0 commit comments

Comments
 (0)