-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfedora-setup-packages
81 lines (76 loc) · 2.8 KB
/
fedora-setup-packages
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
#!/bin/sh
#
# Perform full package upgrade, and installs some basic packages not preinstalled.
#
# NOTE:
# - Originally written for WSL import of docker root filesystem of Fedora 33 and 34,
# from Fedora Container Base image (with dnf) and Fedora Container Minimal
# Base image (with microdnf). Updated for Fedora 35 - 37.
# - Must be run by actual root user, not by use of sudo from regular user,
# (sudo is not installed by default in the Fedora Container Minimal Base image).
# - Interactive! Will prompt user before doing any changes!
# - Skips installation of documentation, by specifying --nodocs as command line
# argument. Standard base image has this configured as default with
# "tsflags=nodocs" in /etc/dns/dns.conf, but this is not supported by microdnf
# so for the minimal base image it must be added on command line.
# - Using "update" command even if has been superseded by "upgrade",
# because it wasn't until Fedora 34 that microdnf supported "upgrade" and
# in both dnf and microdnf "update" still works as an alias for "upgrade"!
#
# Verify running as root
if [ ${EUID:-$(id -u)} -ne 0 ]; then
echo 'Please run this script as root'
exit 1
fi
# Figure out if we have dnf or microdnf (from the Fedora Container Minimal Base image)
if hash dnf > /dev/null 2>&1; then
dnf=dnf
elif hash microdnf > /dev/null 2>&1; then
dnf=microdnf
else
echo 'Package manager dnf or microdnf not found'
exit 1
fi
echo
echo "Upgrading packages..."
if ! $dnf --nodocs --refresh update; then
echo "Failed!"
exit 1
fi
# The tzdata package is already installed, as dependency to glibc,
# but the minimal base image have removed all zoneinfo files and
# forced UTC as timezone.
# WSL automatically sets the timezone of the distro, it creates the /etc/localtime
# symlink to the proper file under /usr/share/zoneinfo matching the configured
# timezone in Windows. To ensure this works as intended, we reinstall the tzdata
# package if zoneinfo files are still missing - if the upgrade command above
# found and installed a new version of tzdata then it will already have
# installed zoneinfo files and reinstall will not be necessary after all.
echo
echo "Checking timezone database..."
if ! rpm --verify tzdata > /dev/null; then
#if [ ! -e /usr/share/zoneinfo ]; then
echo "Reinstalling timezone database to get missing zoneinfo files"
if ! $dnf --nodocs --reinstall tzdata; then
echo "Failed!"
exit 1
fi
else
echo "Timezone database exists"
fi
# Install some basic packages not always preinstalled.
# Note: Fedora 35 and older did not include findutils, but from Fedora 36 it is preinstalled.
echo
echo "Installing basic packages..."
if ! $dnf --nodocs install \
findutils \
unzip \
wget \
nano \
iputils \
iproute \
procps-ng
then
echo "Failed!"
exit 1
fi