-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathset-date-locale-time.sh
61 lines (50 loc) · 1.72 KB
/
set-date-locale-time.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
#!/bin/sh
# Instructions on how to use this script:
# chmod +x SCRIPTNAME.sh
# sudo ./SCRIPTNAME.sh
#
# SCRIPT: set-date-locale-time.sh
# AUTHOR: ALBERT VALBUENA
# DATE: 02-11-2019
# SET FOR: Production
# (For Alpha, Beta, Dev, Test and Production)
#
# PLATFORM: FreeBSD 12/13
#
# PURPOSE: This script installs the sets date and locale on a FreeBSD system
#
# REV LIST:
# DATE: 14-12-2021
# BY: ALBERT VALBUENA
# MODIFICATION: 14-12-2021
#
#
# set -n # Uncomment to check your syntax, without execution.
# # NOTE: Do not forget to put the comment back in or
# # the shell script will not execute!
##########################################################
################ BEGINNING OF MAIN #######################
##########################################################
# Set server time correctly
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
# Change the default pkg repository from quarterly to latest
sed -ip 's/quarterly/latest/g' /etc/pkg/FreeBSD.conf
# Update packages (it will first download the pkg repo from latest)
# secondly it will upgrade any installed packages.
pkg upgrade -y
# Install GNU sed to introduce specific lines
# since FreeBSD's sed is a pain for that specific
pkg install -y gsed
# Set the locale globally
gsed -i '50i\:charset=UTF-8:\\' /etc/login.conf
gsed -i '51i\:lang=xx_XX.UTF-8:' /etc/login.conf
cap_mkdb /etc/login.conf
# Enable NTP (Network Time Protocol) to synchronize time
# and do it also at boot time
sysrc ntpd_enable="YES"
sysrc ntpd_sync_on_start="YES"
# Start time synchronization
service ntpd start
## References:
## https://www.adminbyaccident.com/freebsd/how-to-freebsd/time-and-date-in-freebsd/
## https://www.adminbyaccident.com/freebsd/how-to-freebsd/how-to-set-the-locale-in-freebsd/