-
Notifications
You must be signed in to change notification settings - Fork 0
/
browserscript
114 lines (95 loc) · 4.35 KB
/
browserscript
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
#!/bin/bash
# this script installs Brave Repo and GPG key or the Vivaldi Repo interactively,
# sets their permissions to chown root:root and write-protected,
# and installs Brave stable, beta, nightly or Vivaldi using rpm-ostree
# I silenced all error messages as there where plenty of them. But the commands are all chained together, so if one fails, all fail
BRAVE_BASEURL="https://brave-browser-rpm-release.s3.brave.com" 2> /dev/null
KEY_BASEURL=$BRAVE_BASEURL 2> /dev/null
# change unix permissions and add the correct "system configuration files" SELinux contexts to all repository files
secure_repo_files() {
echo "Securing the repo files against manipulation. Please enter your password one last time."
pkexec sh -c "chown root:root /etc/yum.repos.d/* && \
chmod 744 /etc/yum.repos.d/* && \
chcon -R system_u:object_r:system_conf_t:s0 /etc/yum.repos.d/" || { echo "Failed to secure the repo files!"; exit 1; }
echo
}
add_vivaldi_repo() {
local arch=$1
pkexec sh -c "cat > /etc/yum.repos.d/vivaldi.repo <<'EOF'
[vivaldi]
name=vivaldi
baseurl=https://repo.vivaldi.com/archive/rpm/$arch
enabled=1
gpgcheck=1
gpgkey=https://repo.vivaldi.com/archive/linux_signing_key.pub
EOF"
echo "Vivaldi ($arch) Repo added" &&\
secure_repo_files &&\
echo "installing..."
}
# User input for Brave version
cat <<EOF
======== Browser Install Script ========
Available Browsers:
1: Brave stable (recommended)
2: Brave beta
3: Brave nightly
4: Vivaldi stable (x86_64) (if unsure, use this)
5: Vivaldi stable (arm64) (Snapdragon, Apple Silicon, many SOCs)
6: Vivaldi snapshot (x86_64)
7: Vivaldi snapshot (arm64)
EOF
read -r -p "Which Browser do you want to install? (1-7): " browser_choice
echo
# Determine repository URL and GPG key based on user's choice
case "$browser_choice" in
1)
echo "Downloading Repo and Key, you need to enter a password."
curl -LsS $BRAVE_BASEURL/brave-browser.repo -o /tmp/brave-browser.repo || { echo "Failed to download Brave repo."; exit 1; }
pkexec mv /tmp/brave-browser.repo /etc/yum.repos.d/brave-browser.repo
curl -LsS $KEY_BASEURL/brave-core.asc -o /tmp/brave-core.asc || { echo "Failed to download Brave key"; exit 1; }
pkexec mv /tmp/brave-core.asc /etc/pki/rpm-gpg/brave-core.asc
echo "Brave Repo and Key downloaded." &&\
secure_repo_files &&\
echo "Installing..." &&\
rpm-ostree install brave-browser
;;
2)
echo "Downloading Repo and Key, you need to enter a password."
curl -LsS $BRAVE_BASEURL/brave-browser-beta.repo -o /tmp/brave-browser-beta.repo || { echo "Failed to download Brave repo."; exit 1; }
pkexec mv /tmp/brave-browser-beta.repo /etc/yum.repos.d/brave-browser-beta.repo
curl -LsS $KEY_BASEURL/brave-core-nightly.asc -o /tmp/brave-core-nightly.asc || { echo "Failed to download Brave key."; exit 1; }
pkexec mv /tmp/brave-core-nightly.asc /etc/pki/rpm-gpg/brave-core-nightly.asc
echo "Brave Repo and Key downloaded." &&\
secure_repo_files &&\
echo "Installing..." &&\
rpm-ostree install brave-browser-beta
;;
3)
echo "Downloading Repo and Key, you need to enter a password."
curl -LsS $BRAVE_BASEURL/brave-browser-nightly.repo -o /tmp/brave-browser-nightly.repo || { echo "Failed to download Brave repo."; exit 1; }
pkexec mv /tmp/brave-browser-nightly.repo /etc/yum.repos.d/brave-browser-nightly.repo
curl -LsS $KEY_BASEURL/brave-core-nightly.asc -o /tmp/brave-core-nightly.asc || { echo "Failed to download Brave key"; exit 1; }
pkexec mv /tmp/brave-core-nightly.asc /etc/pki/rpm-gpg/brave-core-nightly.asc
echo "Brave Repo and Key downloaded." &&\
secure_repo_files &&\
echo "Installing..." &&\
rpm-ostree install brave-browser-nightly
;;
4)
add_vivaldi_repo "x86_64" &&\
rpm-ostree install vivaldi-stable ;;
5)
add_vivaldi_repo "aarch64" &&\
rpm-ostree install vivaldi-stable ;;
6)
add_vivaldi_repo "x86_64" &&\
rpm-ostree install vivaldi-snapshot ;;
7)
add_vivaldi_repo "aarch64" &&\
rpm-ostree install vivaldi-snapshot ;;
*)
echo "Invalid choice. You can use 'CTRL c' to exit." &&\
read -r -p "Which Browser do you want to install? (1-7): " browser_choice
;;
esac