mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-21 14:31:02 +02:00
coreos-base/oem-gce: enable oslogin
Enable google cloud oslogin. Use a one-shot systemd unit with ConditionFirstBoot to enable oslogin by flipping some symlinks to oslogin specific ones. Don't do anything if the user has modified one of the files.
This commit is contained in:
parent
4ca2796803
commit
3fbb737589
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ignition": {
|
"ignition": {
|
||||||
"version": "2.1.0"
|
"version": "2.2.0"
|
||||||
},
|
},
|
||||||
"storage": {
|
"storage": {
|
||||||
"files": [
|
"files": [
|
||||||
@ -12,6 +12,14 @@
|
|||||||
},
|
},
|
||||||
"mode": 292
|
"mode": 292
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "root",
|
||||||
|
"path": "/etc/systemd/system/oem-gce-enable-oslogin.service",
|
||||||
|
"contents": {
|
||||||
|
"source": "oem:///units/oem-gce-enable-oslogin.service"
|
||||||
|
},
|
||||||
|
"mode": 292
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"filesystem": "root",
|
"filesystem": "root",
|
||||||
"path": "/etc/hosts",
|
"path": "/etc/hosts",
|
||||||
@ -39,6 +47,10 @@
|
|||||||
{
|
{
|
||||||
"name": "oem-gce.service",
|
"name": "oem-gce.service",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "oem-gce-enable-oslogin.service",
|
||||||
|
"enabled": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
29
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-gce/files/bin/enable-oslogin
vendored
Normal file
29
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-gce/files/bin/enable-oslogin
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# Verify all the config files were not touched by the user. Do not try to
|
||||||
|
# enable oslogin if the user has messed with them
|
||||||
|
|
||||||
|
if [ -e '/etc/pam.d/sshd' ]; then
|
||||||
|
echo '/etc/pam.d/sshd already exists. Not enabling OS Login'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(readlink -f /etc/nsswitch.conf)" != '/usr/share/baselayout/nsswitch.conf' ]; then
|
||||||
|
echo '/etc/nsswitch.conf is not a symlink to /usr/share/baselayout/nsswitch.conf. Not enabling OS Login'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(readlink -f /etc/ssh/sshd_config)" != '/usr/share/ssh/sshd_config' ]; then
|
||||||
|
echo '/etc/ssh/sshd_config is not a symlink to /usr/share/ssh/sshd_config. Not enabling OS Login'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Actually start enabling things. Die if we fail.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir -m 0750 -p '/var/lib/google-sudoers.d'
|
||||||
|
mkdir -m 0750 -p '/var/lib/google-users.d'
|
||||||
|
ln -f -s '/usr/share/google-oslogin/pam_sshd' '/etc/pam.d/sshd'
|
||||||
|
ln -f -s '/usr/share/google-oslogin/nsswitch.conf' '/etc/nsswitch.conf'
|
||||||
|
ln -f -s '/usr/share/google-oslogin/sshd_config' '/etc/ssh/sshd_config'
|
||||||
|
ln -f -s '/usr/share/google-oslogin/oslogin-sudoers' '/etc/sudoers.d/oslogin-sudoers'
|
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Enable GCE OS Login
|
||||||
|
After=local-fs.target
|
||||||
|
ConditionFirstBoot=true
|
||||||
|
Before=sshd.service
|
||||||
|
Before=sshd.socket
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
|
||||||
|
ExecStart=/usr/share/oem/bin/enable-oslogin
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sysinit.target
|
@ -27,4 +27,6 @@ src_install() {
|
|||||||
doins -r "${FILESDIR}/base"
|
doins -r "${FILESDIR}/base"
|
||||||
doins -r "${FILESDIR}/files"
|
doins -r "${FILESDIR}/files"
|
||||||
doins -r "${FILESDIR}/units"
|
doins -r "${FILESDIR}/units"
|
||||||
|
exeinto "/usr/share/oem/bin"
|
||||||
|
doexe "${FILESDIR}/bin/enable-oslogin"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user