457e77cdeec593941b18dd462d3f1415b5760eb1
[csit.git] / resources / tools / disk-image-builder / centos / scripts-remote / serial-console-centos-7-1511.sh
1 #!/bin/sh -e
2
3 # Copyright (c) 2016 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 ##
17 ## Serial console
18 ##
19 echo "********** CONFIGURING SERIAL CONSOLE AND DISABLING IPV6 **********"
20 cat - > /etc/systemd/system/serial-getty-digi@.service <<"_EOF"
21 # ttyS0 - getty
22 #
23 # This service maintains a getty on ttyS0 from the point the system is
24 # started until it is shut down again.
25 #  This file is part of systemd.
26 #
27 #  systemd is free software; you can redistribute it and/or modify it
28 #  under the terms of the GNU Lesser General Public License as published by
29 #  the Free Software Foundation; either version 2.1 of the License, or
30 #  (at your option) any later version.
31
32 [Unit]
33 Description=Serial Getty on %I
34 Documentation=man:agetty(8) man:systemd-getty-generator(8)
35 Documentation=http://0pointer.de/blog/projects/serial-console.html
36 BindsTo=dev-%i.device
37 After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service
38 After=rc-local.service
39
40 # If additional gettys are spawned during boot then we should make
41 # sure that this is synchronized before getty.target, even though
42 # getty.target didn't actually pull it in.
43 Before=getty.target
44 IgnoreOnIsolate=yes
45
46 [Service]
47 ExecStart=-/sbin/agetty -L %I 115200
48 Type=idle
49 Restart=always
50 UtmpIdentifier=%I
51 TTYPath=/dev/%I
52 TTYReset=yes
53 TTYVHangup=yes
54 KillMode=process
55 IgnoreSIGPIPE=no
56 SendSIGHUP=yes
57
58 [Install]
59 WantedBy=getty.target
60 _EOF
61
62 cat - > /etc/default/grub <<"_EOF"
63 # If you change this file, run 'update-grub' afterwards to update
64 # /boot/grub/grub.cfg.
65 # For full documentation of the options in this file, see:
66 #   info -f grub -n 'Simple configuration'
67
68 GRUB_DEFAULT=0
69 GRUB_TIMEOUT=5
70 GRUB_DISABLE_SUBMENU=true
71 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
72 GRUB_CMDLINE_LINUX="rhgb quiet console=tty0 console=ttyS0,115200n8 ipv6.disable=1"
73
74 GRUB_TERMINAL=serial
75 GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
76
77 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
78 #GRUB_DISABLE_LINUX_UUID=true
79
80 # Uncomment to disable generation of recovery mode menu entries
81 #GRUB_DISABLE_RECOVERY="true"
82
83 # Uncomment to get a beep at grub start
84 #GRUB_INIT_TUNE="480 440 1"
85 _EOF
86
87 grub2-mkconfig -o /boot/grub2/grub.cfg
88 sudo systemctl enable serial-getty-digi@ttyS0.service
89 sudo systemctl start serial-getty-digi@ttyS0.service