Repository navigation
Expand file tree
/
Copy pathsetupBasic.sh
More file actions
53 lines (47 loc) · 1.58 KB
/
Copy pathsetupBasic.sh
File metadata and controls
53 lines (47 loc) · 1.58 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
#!/bin/bash
# run this Script as root https://www.linuxjournal.com/content/automatically-re-start-script-root-0
if [[ $UID -ne 0 ]]; then
sudo -p 'Restarting as root, password: ' bash $0 "$@"
exit $?
fi
### Start Script
# Set the new hostname below for quiet setup or leave it blank to be asked
hname=
PACKAGE_LANG=(en_US.UTF-8 de_DE.UTF-8) # the first is fallback in LANGUAGE, the last is set to default
TZ='Europe/Berlin'
# first load the latest software
apt -y update
apt -y full-upgrade
# Timezone
timedatectl set-timezone $TZ
# config the default language, raspi-config is this doing in a similar way
for lang in ${PACKAGE_LANG[*]}; do sed -i -e "s/# $lang/$lang/" /etc/locale.gen; done
dpkg-reconfigure -f noninteractive locales # ? locale-gen
#####
# localectl set-locale LANG=${PACKAGE_LANG[-1]} LANGUAGE=${PACKAGE_LANG[-1]:0:2}:${PACKAGE_LANG[0]:0:2}
# update-locale
#####
update-locale LANG=${PACKAGE_LANG[-1]} LANGUAGE=${PACKAGE_LANG[-1]:0:2}:${PACKAGE_LANG[0]:0:2}
# keyboard settings
localectl set-keymap ${PACKAGE_LANG[-1]:0:2}
# Code from raspi-config
setupcon -k --force <> /dev/tty1 >&0 2>&1
# Hostname
oname=$(hostname)
if [ -z $hname ] ; then
read -p "Hostname "$oname" ändern? Bitte den neuen Hostnamen eingeben, oder einfach enter:" hnameneu
if [[ $hnameneu != "" ]] ; then
hname=$hnameneu
fi
fi
if [[ $hname != "" ]]
then
hostnamectl set-hostname $hname
sed -i s/$oname/$hname/ /etc/hosts
sed -i s/$oname/$hname/ /etc/ssh/*.pub
fi
# Password
# echo "linuxpassword" | passwd --stdin linuxuser
# Reboot
# reboot
echo "Ein reboot ist empfohlen!"