2024-06-03 21:43:42 +01:00
|
|
|
if [ -f ~/.bash_aliases_priv ]; then
|
|
|
|
. ~/.bash_aliases_priv
|
|
|
|
fi
|
2024-09-02 16:21:09 +01:00
|
|
|
alias ssh-host-key='ssh-keyscan localhost | ssh-keygen -lf -'
|
2024-06-03 21:43:42 +01:00
|
|
|
alias weston-phone="weston --width=1920 --height=1056 -S /run/user/1000/wayland-1"
|
|
|
|
alias waydroid-start="waydroid session start"
|
|
|
|
alias waydroid-show="waydroid show-full-ui"
|
|
|
|
alias waydroid-stop="waydroid session stop"
|
|
|
|
alias waydroid-launch="weston-phone && waydroid-start & read && waydroid-stop"
|
|
|
|
alias show-waydroid="waydroid-show"
|
|
|
|
alias swd="waydroid-show"
|
2024-07-24 16:36:46 +01:00
|
|
|
alias launch-waydroid="waydroid-launch"
|
2024-11-14 10:01:32 +00:00
|
|
|
alias screen-off="sleep 0.1 && xset dpms force off"
|
2024-05-30 01:42:30 +01:00
|
|
|
alias boot-sign-verify="sudo sign-boot && sudo verify-boot"
|
2024-11-14 10:01:32 +00:00
|
|
|
alias rdp-session-desktop-cvd="xfreerdp3 ~/Downloads/SessionDesktop.rdpw /gateway:type:arm /sec:aad +clipboard /w:1920 /h:1000 +auto-reconnect"
|
|
|
|
alias pulse-restart="systemctl --user stop pulseaudio.socket pulseaudio.service && sleep 1 && systemctl --user start pulseaudio.socket pulseaudio.service"
|
2024-10-07 17:15:26 +01:00
|
|
|
function conda-activate() {
|
|
|
|
eval "$(~/anaconda3/bin/conda shell.bash hook)";
|
|
|
|
}
|
2024-08-17 14:21:36 +01:00
|
|
|
function kernel-build-dep() {
|
|
|
|
echo "[+] Kernel Build Dependancy Installation...";
|
2024-08-21 14:50:54 +01:00
|
|
|
sudo apt install gawk git dh-make llvm libclang-dev sbsigntool linux-libc-dev libperl-dev libpython3-dev libunwind-dev liblzma-dev lzma-dev libzstd-dev libnuma-dev libelf-dev libcap-dev linux-libc-dev;
|
|
|
|
sudo apt install zlib1g-dev libclang1 zlib1g libbpf0 libzstd1 libnuma1 libelf1;
|
|
|
|
sudo apt install libpython3.10 libunwind8 liblzma5 libcap-ng0 libcap2;
|
2024-08-17 14:21:36 +01:00
|
|
|
sudo apt build-dep linux-image-unsigned-$(uname -r);
|
|
|
|
}
|
2024-05-30 01:42:30 +01:00
|
|
|
function kernel-build() {
|
|
|
|
echo "[+] Kernel Build Starting...";
|
|
|
|
cwd=$(pwd);
|
2024-08-16 18:29:48 +01:00
|
|
|
mkdir -p ~/kernel;
|
2024-05-30 01:42:30 +01:00
|
|
|
cd ~/kernel;
|
2024-08-21 14:31:35 +01:00
|
|
|
doNotContinueKernelBuild=0;
|
2024-08-21 14:50:54 +01:00
|
|
|
if [ -f kernel-build-occuring ]; then
|
|
|
|
echo "[-] Kernel Build Occuring Already!";
|
|
|
|
doNotContinueKernelBuild=1;
|
2024-08-21 14:31:35 +01:00
|
|
|
else
|
2024-08-21 14:50:54 +01:00
|
|
|
touch kernel-build-occuring;
|
|
|
|
fi;
|
|
|
|
if [ $doNotContinueKernelBuild -eq 0 ]; then
|
|
|
|
if [ -f last-build-failed ]; then
|
|
|
|
echo "[*] Resuming last build; delete last-build-failed in the kernel directory before starting a kernel build to re-obtain sources.";
|
|
|
|
rm -f last-build-failed;
|
2024-08-21 14:31:35 +01:00
|
|
|
for _dir in *"linux"*; do
|
|
|
|
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
|
|
|
done;
|
|
|
|
cd "$linuxdir";
|
|
|
|
else
|
2024-08-21 14:50:54 +01:00
|
|
|
for _dir in *"linux"*; do
|
|
|
|
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
|
|
|
done;
|
|
|
|
echo "[-] Removing Sources...";
|
|
|
|
rm -rf "$linuxdir";
|
|
|
|
sudo rm -rf deb-contents;
|
|
|
|
rm -f *.gz;
|
|
|
|
rm -f *.dsc;
|
|
|
|
echo "[*] Archiving old packages...";
|
|
|
|
mkdir -p old-debs;
|
|
|
|
touch dummy.deb;
|
|
|
|
mv *.deb old-debs/;
|
|
|
|
echo "[+] Obtaining Sources...";
|
|
|
|
apt-get source linux-image-unsigned-$(uname -r);
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
for _dir in *"linux"*; do
|
|
|
|
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
|
|
|
done;
|
|
|
|
cd "$linuxdir";
|
|
|
|
echo "[*] Patching source and configuration...";
|
|
|
|
sed -i "s/.*CONFIG_MODULE_SIG_FORCE.*/CONFIG_MODULE_SIG_FORCE policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'ppc64el': 'y', 's390x': 'y'}>/" debian.master/config/annotations;
|
2024-08-21 16:15:21 +01:00
|
|
|
if [ -f certs/system_certificates.S ]; then
|
|
|
|
sed -i 's@.*\.incbin "certs/signing_key\.x509".*@ \.incbin "certs/signing_key\.der"@' certs/system_certificates.S;
|
|
|
|
fi;
|
2024-08-21 14:50:54 +01:00
|
|
|
git apply --verbose ~/Downloads/patches/hibernate/0001-Hibernate-Patch.patch;
|
|
|
|
echo "[*] Cleaning kernel build...";
|
|
|
|
chmod a+x debian/rules;
|
|
|
|
chmod a+x debian/scripts/*;
|
|
|
|
chmod a+x debian/scripts/misc/*;
|
|
|
|
fakeroot debian/rules clean;
|
|
|
|
mkdir -p debian/build/build-generic/certs;
|
|
|
|
sudo cp /cert/mok/signing_key.pem ../ -f;
|
|
|
|
sudo chmod u=rw,g=rw,o=rw ../signing_key.pem;
|
|
|
|
sudo cp /var/lib/shim-signed/mok/MOK.der ../signing_key.x509 -f;
|
|
|
|
sudo chmod u=rw,g=rw,o=rw ../signing_key.x509;
|
2024-08-21 16:15:21 +01:00
|
|
|
cp ../signing_key.x509 debian/build/build-generic/certs/signing_key.der -f;
|
2024-08-21 14:50:54 +01:00
|
|
|
(((until [ -f debian/build/build-generic/certs/signing_key.pem ]; do sleep 0.1; done) && while lsof debian/build/build-generic/certs/signing_key.pem; do sleep 0.1; done) && mv -f ../signing_key.pem debian/build/build-generic/certs/signing_key.pem) &
|
|
|
|
(((until [ -f debian/build/build-generic/certs/signing_key.x509 ]; do sleep 0.1; done) && while lsof debian/build/build-generic/certs/signing_key.x509; do sleep 0.1; done) && mv -f ../signing_key.x509 debian/build/build-generic/certs/signing_key.x509) &
|
|
|
|
else
|
|
|
|
echo "[-] Failed to obtain sources!";
|
|
|
|
doNotContinueKernelBuild=1;
|
|
|
|
rm -f kernel-build-occuring;
|
|
|
|
fi;
|
2024-08-21 14:31:35 +01:00
|
|
|
fi;
|
|
|
|
fi;
|
|
|
|
if [ $doNotContinueKernelBuild -eq 0 ]; then
|
|
|
|
echo "[*] Building kernel...";
|
|
|
|
fakeroot debian/rules binary;
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "[*] Build Complete!";
|
|
|
|
rm -f debian/build/build-generic/certs/signing_key.pem;
|
|
|
|
rm -f ../signing_key.pem;
|
|
|
|
rm -f ../signing_key.x509;
|
|
|
|
echo "[+] Extracting kernel package...";
|
|
|
|
cd ~/kernel;
|
|
|
|
mkdir -p deb-contents;
|
|
|
|
dpkg-deb -R $(ls linux-image-unsigned-* | head -1) deb-contents;
|
|
|
|
cd "$linuxdir";
|
|
|
|
echo "[*] Making kernel signed...";
|
|
|
|
pkgarch=$(dpkg-architecture -qDEB_HOST_ARCH);
|
|
|
|
pkgver=$(dpkg-parsechangelog --show-field Version);
|
|
|
|
cd ~/kernel/deb-contents;
|
|
|
|
pkgunom=$(head -1 DEBIAN/control | sed -e 's/Package: //');
|
|
|
|
find ./ -type f -exec sed -i -e 's/-unsigned//g' {} \;
|
|
|
|
find ./ -type f -exec sed -i -e 's/ unsigned//g' {} \;
|
|
|
|
pkgnom=$(head -1 DEBIAN/control | sed -e 's/Package: //');
|
|
|
|
sudo mv usr/share/doc/$pkgunom usr/share/doc/$pkgnom;
|
|
|
|
tlinuz=$(ls boot/vmlinuz-* | head -1);
|
|
|
|
sudo sbsign --key /cert/BMOK.priv --cert /cert/BMOK.pem $tlinuz --output $tlinuz;
|
|
|
|
sed -i "s/.*Conflicts: .*/Conflicts: $pkgunom/" DEBIAN/control;
|
|
|
|
pkgisz=$(du -ks * | grep -v DEBIAN | cut -f1 | xargs | sed -e 's/\ /+/g' | bc);
|
|
|
|
find ./ -path '*/DEBIAN' -prune -o -type f -exec md5sum {} \; | awk '{ print $1 " " substr($2, 10) }' > DEBIAN/md5sums;
|
|
|
|
sed -i "s/.*Installed-Size: .*/Installed-Size: $pkgisz/" DEBIAN/control;
|
|
|
|
echo "[+] Packing signed kernel...";
|
|
|
|
cd ~/kernel;
|
|
|
|
dpkg-deb -b deb-contents ${pkgnom}_${pkgver}_${pkgarch}.deb;
|
|
|
|
sudo rm -rf deb-contents;
|
|
|
|
echo "[+] Deploying Packages Locally...";
|
|
|
|
sudo cp ${pkgnom}_${pkgver}_${pkgarch}.deb /usr/local/mydebs/;
|
|
|
|
sudo cp linux-headers-* /usr/local/mydebs/;
|
|
|
|
sudo cp linux-libc-dev* /usr/local/mydebs/;
|
|
|
|
sudo cp linux-modules* /usr/local/mydebs/;
|
|
|
|
sudo cp linux-lib-rust* /usr/local/mydebs/;
|
|
|
|
sudo update-mydebs;
|
2024-08-21 14:50:54 +01:00
|
|
|
rm -f kernel-build-occuring;
|
2024-08-21 14:31:35 +01:00
|
|
|
cd "$cwd";
|
|
|
|
echo "[+] Kernel Build Finished!";
|
|
|
|
else
|
|
|
|
echo "[*] Build Failed!";
|
|
|
|
cd ~/kernel;
|
|
|
|
touch last-build-failed;
|
2024-08-21 14:50:54 +01:00
|
|
|
rm -f kernel-build-occuring;
|
2024-08-21 14:31:35 +01:00
|
|
|
cd "$cwd";
|
|
|
|
fi;
|
|
|
|
fi;
|
2024-05-30 01:42:30 +01:00
|
|
|
}
|
|
|
|
function install-tar() {
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
if [ $# -eq 1 ]; then
|
|
|
|
fln=$(basename -- "$1");
|
|
|
|
flp=$1;
|
|
|
|
else
|
|
|
|
fln=$(basename -- "$2");
|
|
|
|
flp=$2;
|
|
|
|
fi
|
|
|
|
fln="${fln%%.*}";
|
|
|
|
echo "Installing: /opt/$fln";
|
|
|
|
sudo mkdir -p "/opt/$fln";
|
|
|
|
sudo tar -xvf "$flp" -C /opt/$fln;
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
sudo chown -R "$1" /opt/$fln;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Usage:";
|
|
|
|
echo "install-tar <archive> | <owner> <archive>";
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function install-tar-contents() {
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
if [ $# -eq 1 ]; then
|
|
|
|
flp=$1;
|
|
|
|
else
|
|
|
|
flp=$2;
|
|
|
|
fi
|
|
|
|
echo "Installing: /opt";
|
|
|
|
sudo tar -xvf "$flp" -C /opt;
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
sudo chown -R "$1" /opt;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Usage:";
|
|
|
|
echo "install-tar-contents <archive> | <owner> <archive>";
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function edit-dot-desktop() {
|
|
|
|
sudo nano "/usr/share/applications/$(basename -- "$1").desktop";
|
|
|
|
}
|
|
|
|
function edit-dot-desktop-local() {
|
|
|
|
nano ~"/.local/share/applications/$(basename -- "$1").desktop";
|
|
|
|
}
|
|
|
|
function tpm2-contents() {
|
|
|
|
sudo tpm2_selftest
|
|
|
|
sudo tpm2_gettestresult
|
|
|
|
sudo tpm2_getcap -l
|
|
|
|
sudo tmp2_pcrread
|
|
|
|
sudo tpm2_pcrread
|
|
|
|
}
|
2024-05-30 18:29:36 +01:00
|
|
|
alias list-xinput-devices="xinput list"
|
|
|
|
function disable-xinput-device() {
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
echo "Provide a device name fragment.";
|
|
|
|
else
|
|
|
|
cdid=$(xinput list | grep "$1" | head -1 | grep -Po 'id=\K[^\t]*' | head -1);
|
|
|
|
echo "Disabling: $cdid";
|
|
|
|
xinput disable $cdid;
|
|
|
|
fi;
|
|
|
|
}
|
|
|
|
function enable-xinput-device() {
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
echo "Provide a device name fragment.";
|
|
|
|
else
|
|
|
|
cdid=$(xinput list | grep "$1" | head -1 | grep -Po 'id=\K[^\t]*' | head -1);
|
|
|
|
echo "Enabling: $cdid";
|
|
|
|
xinput enable $cdid;
|
|
|
|
fi;
|
|
|
|
}
|
2024-07-24 16:36:46 +01:00
|
|
|
function record-screen-x11() {
|
|
|
|
cwd=$(pwd);
|
|
|
|
cd ~/Videos;
|
|
|
|
mkdir -p ScreenRecordings;
|
|
|
|
cd ScreenRecordings;
|
|
|
|
srecfname="recording_"$(date '+%Y-%m-%d_%H-%M-%S')".mkv";
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
srecintv="$1";
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
srecfname="$2";
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
srecintv='1';
|
|
|
|
fi
|
|
|
|
echo "Recording x11 screen to ${srecfname} every ${srecintv}s at 30 fps.";
|
|
|
|
ffmpeg -framerate "$srecintv" -f x11grab -s 1920,1080 -i :0.0+0,0 -vf settb=\(1/30\),setpts=N/TB/30 -r 30 -vcodec libx264 -crf 0 -preset ultrafast -threads 0 "$srecfname";
|
|
|
|
cd "$cwd";
|
|
|
|
}
|
2024-08-17 17:33:29 +01:00
|
|
|
function search-in-files() {
|
2024-11-14 10:01:32 +00:00
|
|
|
grep -Rn "$1" -e "$2";
|
|
|
|
}
|
|
|
|
function search-word-in-files() {
|
2024-08-17 17:33:29 +01:00
|
|
|
grep -Rnw "$1" -e "$2";
|
|
|
|
}
|
2024-08-21 16:15:21 +01:00
|
|
|
function apt-search() {
|
|
|
|
apt list | grep "$1";
|
|
|
|
}
|
|
|
|
function apt-search-installed() {
|
|
|
|
apt list --installed | grep "$1";
|
|
|
|
}
|
2024-09-02 16:21:09 +01:00
|
|
|
function attach-raw-img() {
|
|
|
|
sudo udisksctl loop-setup -f "$1";
|
|
|
|
}
|
2024-09-14 16:36:28 +01:00
|
|
|
function attach-raw-img-ro() {
|
|
|
|
sudo udisksctl loop-setup -f "$1" -r;
|
|
|
|
}
|
2024-09-02 16:21:09 +01:00
|
|
|
function dettach-raw-img() {
|
|
|
|
sudo udisksctl loop-delete -b "$1";
|
|
|
|
}
|