stream-clients/pack-browsers.sh

65 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2021-06-15 11:43:19 +00:00
#!/usr/bin/env sh
2021-06-15 11:38:01 +00:00
dir=$(dirname $(realpath $0))
2021-06-15 13:10:49 +00:00
temp_name=$(head -c 20 /dev/random | xxd -p | tr -dc a-f0-9)
temp_dir="/tmp/${temp_name}"
chrome_dir="${temp_dir}/chrome"
2021-06-15 15:28:47 +00:00
2022-03-05 18:33:56 +00:00
if [[ ! -n "${DRONE_TAG}" ]]
then
export DRONE_TAG=$(git describe --abbrev=0 | tr -dc v0-9)
fi
2022-03-05 18:41:02 +00:00
mkdir -p "${dir}/out"
rm -rf "${dir}/out"
2022-03-05 18:33:56 +00:00
2021-06-15 15:28:47 +00:00
mkdir -p "${temp_dir}/out"
2021-06-15 13:10:49 +00:00
mkdir -p "${chrome_dir}"
2021-06-15 13:35:34 +00:00
if [[ "${CHROME_PRIVKEY}test" == "test" ]]
then
cp "${HOME}/keys/chrome-privkey.pem" "${temp_dir}/privkey.pem"
else
echo "${CHROME_PRIVKEY}" > "${temp_dir}/privkey.pem"
fi
2021-06-15 13:10:49 +00:00
if [[ "${DBUS_SESSION_BUS_ADDRESS}test" == "test" ]]
then
2021-06-15 13:13:50 +00:00
export DBUS_SYSTEM_BUS_ADDRESS="unix:path=${temp_dir}/dbus-system.sock"
export DBUS_SESSION_BUS_ADDRESS="unix:path=${temp_dir}/dbus-session.sock"
dbus-daemon --system --address="${DBUS_SYSTEM_BUS_ADDRESS}" &
2021-06-15 13:10:49 +00:00
dbus-daemon --session --address="${DBUS_SESSION_BUS_ADDRESS}" &
fi
2022-03-05 18:41:02 +00:00
if [[ ! -n "${DISPLAY}" ]]
2021-06-15 13:10:49 +00:00
then
export DISPLAY=:8819
Xvfb "${DISPLAY}" &
fi
2021-06-15 12:44:12 +00:00
2022-03-05 19:07:41 +00:00
echo "DRONE_TAG=${DRONE_TAG}"
echo "DISPLAY=${DISPLAY}"
2021-06-15 11:38:01 +00:00
${dir}/icons.sh
2021-06-15 12:44:12 +00:00
browser=$(which chromium-browser 2> /dev/null)
if [[ "$?" -ne "0" ]]
then
browser=$(which chromium 2> /dev/null)
fi
2021-06-15 15:32:31 +00:00
release_folder="${temp_dir}/out/proxy-stream-${DRONE_TAG}"
cp -r "${dir}/chrome" "${release_folder}"
2021-06-15 15:28:47 +00:00
2022-10-16 19:17:23 +00:00
(cd "${release_folder}" && zip -r "${temp_dir}/out/proxy-stream-${DRONE_TAG}.xpi" .)
2022-03-05 18:41:02 +00:00
if grep "/proc/1/cgroup" -q -F -e docker
then
${browser} --disable-gpu --no-sandbox --user-data-dir=${chrome_dir} --pack-extension="${temp_dir}/out/proxy-stream-${DRONE_TAG}" --pack-extension-key="${temp_dir}/privkey.pem"
else
${browser} --user-data-dir=${chrome_dir} --pack-extension="${temp_dir}/out/proxy-stream-${DRONE_TAG}" --pack-extension-key="${temp_dir}/privkey.pem"
fi
2021-06-15 11:38:01 +00:00
2021-06-15 15:32:31 +00:00
rm -rf "${release_folder}"
mv "${temp_dir}/out" "${dir}/out"
2021-06-15 11:38:01 +00:00
rm -rf ${temp_dir}