-
-
Save WinkelCode/dffeb181a4c7903cbc463169324f61b8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# This script is unmaintained | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# This script is unmaintained | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# This script is unmaintained | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
# Please check out these fork(s) instead | |
# https://gist.github.com/zany130/ba610a7391fcee4e4e7a20cbd06bc754 | |
# * more might be in the gist's comments | |
set -e # Exit on error | |
if [ "$EUID" -ne 0 ]; then | |
echo "To ensure correct permissions, this script must be run as root." | |
exit 1 | |
fi | |
install_location="/var/lib/safing-portmaster" # Must not include trailing slash | |
echo "-> Creating Portmaster program directory at '${install_location}'" | |
mkdir -p "${install_location}" | |
echo "-> Creating Portmaster exports directory at '${install_location}/exports'" | |
mkdir -p "${install_location}/exports/share/applications" | |
mkdir -p "${install_location}/exports/share/icons" | |
mkdir -p "${install_location}/exports/units" | |
temp_dir=$(mktemp -d) | |
echo "-> Downloading 'portmaster-start'" | |
wget -q --show-progress -O "$temp_dir/portmaster-start" https://updates.safing.io/latest/linux_amd64/start/portmaster-start | |
echo "-> Downloading 'portmaster.service'" | |
wget -q --show-progress -O "$temp_dir/portmaster.service" https://raw.githubusercontent.com/safing/portmaster-packaging/master/linux/portmaster.service | |
echo "-> Downloading 'portmaster.desktop'" | |
wget -q --show-progress -O "$temp_dir/portmaster.desktop" https://raw.githubusercontent.com/safing/portmaster-packaging/master/linux/portmaster.desktop | |
echo "-> Downloading 'portmaster_notifier.desktop'" | |
wget -q --show-progress -O "$temp_dir/portmaster_notifier.desktop" https://raw.githubusercontent.com/safing/portmaster-packaging/master/linux/portmaster_notifier.desktop | |
echo "-> Downloading 'portmaster_logo.png'" | |
wget -q --show-progress -O "$temp_dir/portmaster_logo.png" https://raw.githubusercontent.com/safing/portmaster-packaging/master/linux/portmaster_logo.png | |
echo "-> Patching paths in 'portmaster.service'" | |
sed -i "s|/opt/safing/portmaster|${install_location}|g" "$temp_dir/portmaster.service" | |
echo "-> Patching paths in 'portmaster.desktop'" | |
sed -i "s|/opt/safing/portmaster|${install_location}|g" "$temp_dir/portmaster.desktop" | |
echo "-> Patching paths in 'portmaster_notifier.desktop'" | |
sed -i "s|/opt/safing/portmaster|${install_location}|g" "$temp_dir/portmaster_notifier.desktop" | |
echo "-> Installing 'portmaster-start' and setting security context" | |
install -m 0755 "$temp_dir/portmaster-start" "${install_location}/portmaster-start" | |
chcon -t bin_t "${install_location}/portmaster-start" | |
echo "-> Installing 'portmaster.service'" | |
install -m 0644 "$temp_dir/portmaster.service" "${install_location}/exports/units/portmaster.service" | |
echo "-> Installing 'portmaster.desktop'" | |
install -m 0644 "$temp_dir/portmaster.desktop" "${install_location}/exports/share/applications/portmaster.desktop" | |
echo "-> Installing 'portmaster_notifier.desktop'" | |
install -m 0644 "$temp_dir/portmaster_notifier.desktop" "${install_location}/exports/share/applications/portmaster_notifier.desktop" | |
echo "-> Installing 'portmaster_logo.png' (as 'portmaster.png')" | |
install -m 0644 "$temp_dir/portmaster_logo.png" "${install_location}/exports/share/icons/portmaster.png" | |
echo "-> Running 'portmaster-start update' to download Portmaster data" | |
"${install_location}/portmaster-start" update --data="${install_location}" | |
echo "-> (Workaround) Moving 'portmaster.service' to '/etc/systemd/system' and reverse-symlinking it since systemd wants units on the same filesystem" | |
mv "${install_location}/exports/units/portmaster.service" /etc/systemd/system/portmaster.service | |
ln -s /etc/systemd/system/portmaster.service "${install_location}/exports/units/portmaster.service" | |
echo "-> Enabling 'portmaster' service" | |
systemctl daemon-reload | |
systemctl enable "portmaster.service" | |
echo "-> Creating 'portmaster_notifier' autostart" | |
ln -s "${install_location}/exports/share/applications/portmaster_notifier.desktop" /etc/xdg/autostart/portmaster_notifier.desktop | |
echo "-> Adding '$install_location' to \$XDG_DATA_DIRS to show desktop entries (applies after next login)" | |
echo "XDG_DATA_DIRS=$install_location/exports/share:\$XDG_DATA_DIRS" >/etc/profile.d/zzz-portmaster-to-xdg-data-dirs.sh # We prepend 'zzz' since profile.d scripts aren't numbered on Fedora, and we want to run after any other scripts that modify XDG_DATA_DIRS. | |
echo "-> Removing '${temp_dir}'" | |
rm -rf "$temp_dir" | |
echo "-> Done, Portmaster and its tray/notifier application will start with the next boot." |
I managed to get the new V2 script to work in Bazzite. Here it is https://gist.github.com/zany130/ba610a7391fcee4e4e7a20cbd06bc754
Sorry for not updating guys. I no longer use Linux desktop and never got around to deprecating this script. My apologies.
I put a big comment at the top that says it's now unmaintained and links to @zany130 's fork. If there are any others to add, please let me know @S7venLights
I managed to get the new V2 script to work in Bazzite. Here it is https://gist.github.com/zany130/ba610a7391fcee4e4e7a20cbd06bc754
Thanks, would this keep my config/settings when I upgrade and can you advise if it does everything that the official manual installation script does/requires?
can you advise if it does everything that the official manual installation script does/requires?
I based it on the official manual installation; all I did was change the paths it uses ( and make them configurable). I did reuse some of @WinkelCode code to tell the system to look in our custom paths for some of the stuff https://gist.github.com/zany130/ba610a7391fcee4e4e7a20cbd06bc754#file-install_portmaster_to_var_v2-sh-L172
The one thing I didn't do that the official script does is
ln -sf /usr/lib/portmaster/portmaster-ui-start.sh /usr/bin/portmaster
Because on immutable distros like bazzite, /usr/bin
is not writable, so I stored all the binaries (ui-start script and portmaster binary) in /var/lib/portmaster/bin
and I didn't bother to symlink it anywhere because there isn't anywhere to symlink it to that would be on the system path by default and is mutable
So, on an official install of Portmaster, you would see the app menu desktop file launches
/usr/bin/portmaster
(which is really running the ui-start.sh script which adds some env vars and launches the real portmaster
binary)
And with my script, it's
/usr/bin/portmaster-ui-start.sh
Thanks, would this keep my config/settings when I upgrade,
As for settings, I intentionally used a different path from @WinkelCode just in case v2 is not compatible with v1 settings (I'm not sure if they are). Also, some of the files are different, so it's better to do a clean install.
That said, all your old settings and stuff should still be at
/var/lib/safing-portmaster
Specifically, the config.json
you could copy that into /var/lib/portmaster
Many thanks @zany130 for the detailed explanation, I will report back if the settings are incompatible or compatible.
For the benefit of anyone trying Portmaster, how does one uninstall Portmaster from either of these scripts?
really all you have to do is systemctl disable --now
the service and rm the folder that portmaster was installed to.
the only files that are created outside of the portmaster folder are a symlink to the service at
"${systemd_dir}/portmaster.service"
and
/etc/profile.d/zzz-portmaster-to-xdg-data-dirs.sh
which is for adding the exports folder to your path
https://wiki.safing.io/en/Portmaster/Install/Linux#manual-installation-script
so assuming the paths in the script were left at default this is how i would uninstall everyting
systemctl disable --now portmaster.service
sudo rm -rf /var/lib/portmaster
sudo rm /etc/systemd/system/portmaster.service
sudo rm /etc/profile.d/zzz-portmaster-to-xdg-data-dirs.sh
I just updated using Zany130's script and it seems peachy so far (although there was one issue) I wrote an upgrade install guide here.
@WinkelCode I see Portmaster V2 has reached Linux now and it states it has better support for Immutable OS's It requires a re-install, but as mentioned here it's still not clear what installation method to use for immutable OS, specifically Fedora based ones.
Is it manual installation script or RPM?
Let us know if there's any specific thing we need to do to to update from an installation that used your script.
I see the manual install script installs at: /usr/lib/portmaster and yours at /var/lib/safing-portmaster so I guess they're not compatible so please advise the best way forward