This repository was archived by the owner on May 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_my_flatpak_apps.sh
More file actions
144 lines (125 loc) · 4.52 KB
/
install_my_flatpak_apps.sh
File metadata and controls
144 lines (125 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env bash
# Ensure the script is run as root
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root!"
exit 1
fi
# Set the target user (who invoked the script with sudo)
target_user="${SUDO_USER:-$(logname)}"
target_home="/home/$target_user"
# Flatpak installation and setup script
# Color Variables
CYAN_B='\033[1;96m'
YELLOW='\033[0;93m'
RED_B='\033[1;31m'
RESET='\033[0m'
GREEN='\033[0;32m'
PURPLE='\033[0;35m'
# Remote origin to use for installations
flatpak_origin='flathub'
# List of desktop apps to be installed (specified by app ID)
flatpak_apps=(
'com.valvesoftware.Steam'
'com.github.IsmaelMartinez.teams_for_linux'
'dev.vencord.Vesktop'
'org.telegram.desktop'
'com.spotify.Client'
'chat.simplex.simplex'
'io.itch.itch'
'com.heroicgameslauncher.hgl'
'com.ultimaker.cura'
'com.dec05eba.gpu_screen_recorder'
'com.obsproject.Studio'
'com.obsproject.Studio.Plugin.DistroAV'
'io.github.libvibrant.vibrantLinux'
'com.rustdesk.RustDesk'
'org.localsend.localsend_app'
'net.davidotek.pupgui2'
'dev.lizardbyte.app.Sunshine'
'com.moonlight_stream.Moonlight'
'net.mullvad.MullvadBrowser'
'io.github.ungoogled_software.ungoogled_chromium'
'com.github.tchx84.Flatseal'
'dev.deedles.Trayscale'
'com.github.wwmm.easyeffects'
)
# Detect file system type of the root partition
root_fs_type=$(df -T / | awk 'NR==2 {print $2}')
# Determine whether to use the --user flag
if [[ "$root_fs_type" == "btrfs" ]]; then
flatpak_user_flag=""
else
flatpak_user_flag="--user"
fi
# Check if Flatpak is installed; if not, install it via Pacman
if ! command -v flatpak &> /dev/null; then
echo -e "${PURPLE}Flatpak is not installed. Installing Flatpak...${RESET}"
pacman -S --needed --noconfirm flatpak
fi
# Prompt the user to proceed with installation
echo -e "${CYAN_B}Would you like to install Dillacorn's chosen Flatpak applications? (y/n)${RESET}"
read -n 1 -r REPLY
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Flatpak setup and install canceled by the user...${RESET}"
exit 0
fi
# Add Flathub repository for user-level installations if --user flag is being used
if [[ -n "$flatpak_user_flag" ]]; then
echo -e "${GREEN}Adding Flathub repository for user-level installations...${RESET}"
runuser -u "$target_user" -- flatpak $flatpak_user_flag remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
fi
# Update currently installed Flatpak apps (as the non-root user)
echo -e "${GREEN}Updating installed Flatpak apps...${RESET}"
runuser -u "$target_user" -- flatpak $flatpak_user_flag update -y
# Retry logic for Flatpak installation
install_flatpak_app() {
local app="$1"
local retries=3
local count=0
while ! runuser -u "$target_user" -- flatpak $flatpak_user_flag list --app | grep -q "${app}"; do
if [ $count -ge $retries ]; then
echo -e "${RED_B}Failed to install ${app} after $retries attempts. Skipping...${RESET}"
return 1
fi
echo -e "${GREEN}Installing ${app} (Attempt $((count + 1))/${retries})...${RESET}"
# Install the Flatpak app as the non-root user
if runuser -u "$target_user" -- flatpak $flatpak_user_flag install -y "$flatpak_origin" "$app"; then
echo -e "${GREEN}${app} installed successfully.${RESET}"
break
else
install_status=$?
if [ "$install_status" -eq 0 ]; then
echo -e "${YELLOW}${app} is already installed. Skipping...${RESET}"
break
else
echo -e "${RED_B}Failed to install ${app}. Retrying...${RESET}"
count=$((count + 1))
sleep 2
fi
fi
done
}
# Install apps from the list (as the non-root user)
echo -e "${GREEN}Installing selected Flatpak apps...${RESET}"
for app in "${flatpak_apps[@]}"; do
if ! runuser -u "$target_user" -- flatpak $flatpak_user_flag list --app | grep -q "${app}"; then
install_flatpak_app "${app}"
else
echo -e "${YELLOW}${app} is already installed. Skipping...${RESET}"
fi
done
# Configure firewall rules for NDI (as root, since this requires system-level changes)
echo -e "${CYAN}Configuring firewall rules for NDI...${RESET}"
# Add firewall rules for NDI (ports 5959-5969, 6960-6970, 7960-7970 for TCP and UDP, and 5353 for mDNS)
echo -e "${CYAN}Adding firewall rules...${RESET}"
ufw allow 5353/udp
ufw allow 5959:5969/tcp
ufw allow 5959:5969/udp
ufw allow 6960:6970/tcp
ufw allow 6960:6970/udp
ufw allow 7960:7970/tcp
ufw allow 7960:7970/udp
ufw allow 5960/tcp
echo -e "${GREEN}Firewall rules for NDI configured successfully.${RESET}"
echo -e "${PURPLE}Flatpak setup and installation complete.${RESET}"