-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_fedora.sh
executable file
·112 lines (91 loc) · 3.83 KB
/
setup_fedora.sh
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
#!/bin/bash
# Author: https://github.com/zcavaleiro
# Safe exit of script
set -euo pipefail
# Declaring Initial Vars
CONFIG_FILE="fedora_apps.json"
APP_DIR="$HOME/Applications"
# Verify its a distro from RHEL Family
if grep -qEi "fedora|centos|rocky|rhel" /etc/*release; then
OS="RHEL"
else
echo "Sistema Operativo não suportado"
exit 1
fi
# Set hostname
echo "Lets give a name to the OS machine"
read -rp 'hostname: ' myhostname
sudo hostnamectl set-hostname "$myhostname"
# Configuring /etc/dnf/dnf.conf
sudo bash -c 'echo -e "\nfastestmirror=true\nmax_parallel_downloads=10\ndeltarpm=true" >> /etc/dnf/dnf.conf'
# Enable RPM Repositories Free e Non-Free
sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
sudo dnf update -y
sudo dnf upgrade --refresh -y
# Group multimedia codecs install
#dnf group upgrade --with-optional Multimedia -y # error
# Instaling OS packages
echo '# -------------- zcavaleiro:dotfiles Instaling defined OS packages and dependencies (jq or yp?)---------------'
# Function to read packages, urls and dirs from the json file.
read_config() {
local file=$1
jq -r '.packages[]' "$file"
jq -c '.applications[]' "$file"
jq -r '.signed_packages[]' "$file"
}
# Reading packages, urls, directories and signed packeges from config file
PACKAGES=$(jq -r '.packages[]' "$CONFIG_FILE")
APPLICATIONS=$(jq -c '.applications[]' "$CONFIG_FILE")
SIGNED_PACKAGES=$(jq -r '.signed_packages[]' "$CONFIG_FILE")
# Instaling System Packages
for PACKAGE in $PACKAGES; do
sudo dnf install -y $PACKAGE
done
# Instaling apps with key signature
echo '# -------------- zcavaleiro:dotfiles Instaling apps with key ---------------'
for SIGNED_PACKAGE in $SIGNED_PACKAGES; do
case $SIGNED_PACKAGE in
"vscode")
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null
sudo dnf check-update
sudo dnf install -y code
;;
"brave")
sudo dnf install -y dnf-plugins-core
sudo dnf-3 config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
sudo dnf install -y brave-browser
;;
*)
echo "Pacote assinado desconhecido: $SIGNED_PACKAGE"
;;
esac
done
# App download, extract and create a desktop dir shortcut from url
echo '# -------------- zcavaleiro:dotfiles Download, extract and create a desktop shortcut ---------------'
mkdir -p $APP_DIR
# Workaround detecting Desktop name by language
DESKTOP_DIR="$HOME/Desktop"
if [ ! -d "$DESKTOP_DIR" ]; then
DESKTOP_DIR="$HOME/Área de Trabalho"
fi
# Download and extract files to each tmp dir
for application in $APPLICATIONS; do
URL=$(echo "$application" | jq -r '.url')
DIR=$(echo "$application" | jq -r '.dir')
TEMP_DIR=$(mktemp -d)
wget -P $TEMP_DIR $URL
FILE_NAME=$(basename $URL)
mkdir -p $APP_DIR/$DIR
if [[ $FILE_NAME == *.tar.gz ]]; then
tar -xzf $TEMP_DIR/$FILE_NAME -C $APP_DIR/$DIR
elif [[ $FILE_NAME == *.tar ]]; then
tar -xf $TEMP_DIR/$FILE_NAME -C $APP_DIR/$DIR
fi
rm -rf $TEMP_DIR
# Create shortcut in "desktop" - "Area de trabalho"
echo -e "[Desktop Entry]\nName=$DIR\nExec=xdg-open $APP_DIR/$DIR\nType=Application\nTerminal=false\nIcon=folder" > "$DESKTOP_DIR/$DIR.desktop"
chmod +x "$DESKTOP_DIR/$DIR.desktop"
done