Streamline installation of all further software

This commit is contained in:
Manuel Thalmann 2024-07-17 14:18:27 +02:00
commit 719a9ab8ff
36 changed files with 679 additions and 9 deletions

View file

@ -1,59 +0,0 @@
#!/bin/bash
BROWSER_BIN="${BROWSER_BIN}";
EXTENSION_NAME="${EXTENSION_NAME}";
UNPACKED_EXTENSION="${UNPACKED_EXTENSION}";
EXTENSION_DIR="${EXTENSION_DIR}";
EXTENSION_POLICY_DIR="${EXTENSION_POLICY_DIR}";
# Elevate script
if [ ! "$UID" -eq 0 ]
then
sudo \
BROWSER_BIN="${BROWSER_BIN}" \
EXTENSION_NAME="${EXTENSION_NAME}" \
UNPACKED_EXTENSION="${UNPACKED_EXTENSION}" \
EXTENSION_DIR="${EXTENSION_DIR}" \
EXTENSION_POLICY_DIR="${EXTENSION_POLICY_DIR}" \
bash "$BASH_SOURCE" "$USER";
else
keyFile="$UNPACKED_EXTENSION.pem";
extensionFile="$UNPACKED_EXTENSION.crx";
manifestFile="$UNPACKED_EXTENSION/manifest.json";
destination="$EXTENSION_DIR/$EXTENSION_NAME.crx";
sudo -u "$1" "${BROWSER_BIN}" --pack-extension="$UNPACKED_EXTENSION";
# Tamper manifest file
manifest="$(cat "$manifestFile" | jq ". + {key: "'"'"$(openssl rsa -in "$keyFile" -pubout -outform DER | openssl base64 -A)"'"'"}")";
echo "$manifest" | sudo -u "$1" tee "$manifestFile" > /dev/null;
# Pack extension
extensionID="$(openssl rsa -in "$keyFile" -pubout -outform DER | sha256sum | head -c32 | tr 0-9a-f a-p)";
extensionVersion="$(cat "$manifestFile" | jq -r '.version')";
sudo -u "$1" "${BROWSER_BIN}" --pack-extension="$UNPACKED_EXTENSION" --pack-extension-key="$keyFile";
# Install extension and preinstall it
mkdir -p "$EXTENSION_DIR";
cp "$extensionFile" "$destination";
chmod -R a+rx "$EXTENSION_DIR";
chmod -R u+w "$EXTENSION_DIR";
mkdir -p "$EXTENSION_POLICY_DIR";
crxProperty="external_crx";
find "$EXTENSION_POLICY_DIR" -name "*.json" -print0 |
while IFS= read -r -d "" file
do
if [ "$(cat "$file" | jq -r ".$crxProperty")" == "$destination" ]
then
rm "$file";
fi;
done;
{
echo "{";
echo ' "external_crx": "'"$destination"'",';
echo ' "external_version": "'"$extensionVersion"'"';
echo "}";
} | tee "$EXTENSION_POLICY_DIR/$extensionID.json" > /dev/null;
fi

View file

@ -1,33 +0,0 @@
#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
BROWSER_BIN="${BROWSER_BIN}";
EXTENSION_DIR="${EXTENSION_DIR}";
EXTENSION_POLICY_DIR="${EXTENSION_POLICY_DIR}";
archiveName="$(mktemp)";
extensionDir="$(mktemp -d)";
manifestFile="$extensionDir/manifest.json";
chmod a+rwx "$extensionDir";
# Download `youtube-music-dl`
wget https://github.com/dougppaz/youtube-music-dl/releases/download/v1.2.1/youtube-music-dl.zip -O "$archiveName";
# Prepare extension
mkdir -p "$extensionDir";
unzip "$archiveName" -d "$extensionDir";
rm "$archiveName";
# Tamper manifest file
manifest="$(cat "$manifestFile" | jq ".background.persistent = false")";
echo "$manifest" > "$manifestFile";
BROWSER_BIN="${BROWSER_BIN}" \
EXTENSION_NAME="youtube-music-dl" \
UNPACKED_EXTENSION="$extensionDir" \
EXTENSION_DIR="${EXTENSION_DIR}" \
EXTENSION_POLICY_DIR="${EXTENSION_POLICY_DIR}" \
. ./install-extension.sh;
rm -rf "$extensionDir";
popd > /dev/null;

View file

@ -1,7 +0,0 @@
#!/bin/bash
if [ "$XDG_SESSION_TYPE" == "wayland" ]
then
export MOZ_ENABLE_WAYLAND=1
else
export MOZ_USE_XINPUT2=1
fi

View file

@ -1,4 +1,4 @@
#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
sudo cp ./firefox.sh /etc/profile.d/;
sudo cp ../../Software/firefox/firefox.sh /etc/profile.d/;
popd > /dev/null;

View file

@ -1,5 +1,5 @@
#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
pushd "${BASH_SOURCE%/*}/../../Software/rclone" > /dev/null;
sudo cp "rclone.service" "rclone.target" "rclone@.service" /etc/systemd/user;
systemctl enable --user rclone;

View file

@ -1,10 +0,0 @@
[Unit]
Description=rclone Service Starter
Documentation=man:rclone(1)
[Service]
Type=simple
ExecStart=bash -c 'sleep 10; systemctl --user start rclone.target'
[Install]
WantedBy=default.target

View file

@ -1,3 +0,0 @@
[Unit]
Description=rclone Mounts
Documentation=man:rclone(1)

View file

@ -1,35 +0,0 @@
[Unit]
Description=rclone: Remote FUSE filesystem for cloud storage config %i
Documentation=man:rclone(1)
[Service]
Type=notify
Environment="EXPRESSION=%i"
ExecStart= \
bash -c ' \
args=; \
target="$(echo "$EXPRESSION" | cut -d":" -f1)"; \
dirname="$(echo "$EXPRESSION" | cut -d":" -f2)"; \
cacheDuration="$(echo "$EXPRESSION" | cut -d":" -f3)"; \
\
if [ ! -z "$cacheDuration" ]; \
then \
args="--vfs-cache-max-age=$cacheDuration"; \
fi; \
\
destination="`cd "%h/.mnt"; realpath -m "$dirname"`"; \
mkdir -p "$destination"; \
mkdir -p /tmp/rclone; \
/usr/bin/rclone mount \
--config="%h/.config/rclone/rclone.conf" \
--vfs-cache-mode full \
--log-file /tmp/rclone/$target.log \
$args \
$target: "$destination";'
ExecStop=bash -c '/bin/fusermount -zu "`cd "%h/.mnt"; realpath "$(echo "$EXPRESSION" | cut -d":" -f2)"`"'
Restart=always
RestartSec=10
[Install]
WantedBy=rclone.target