Wizard: encode satellite cmd properly

This commit is contained in:
Lukas Zapletal 2025-05-12 17:11:21 +02:00 committed by Klara Simickova
parent 24fdc1147f
commit 1a3a0ecc03
2 changed files with 18 additions and 19 deletions

View file

@ -473,9 +473,7 @@ const getSatelliteCommand = (files?: File[]): string => {
const satelliteCommandFile = files?.find(
(file) => file.path === '/usr/local/sbin/register-satellite'
);
return satelliteCommandFile?.data
? decodeURIComponent(atob(satelliteCommandFile.data))
: '';
return satelliteCommandFile?.data ? atob(satelliteCommandFile.data) : '';
};
const uploadTypeByTargetEnv = (imageType: ImageTypes): UploadTypes => {
@ -587,7 +585,8 @@ const getCustomizations = (state: RootState, orgID: string): Customizations => {
});
files.push({
path: '/usr/local/sbin/register-satellite',
data: btoa(encodeURIComponent(satCmd)),
data: btoa(satCmd),
mode: '0774',
data_encoding: 'base64',
ensure_parents: true,
});

View file

@ -263,23 +263,23 @@ WantedBy=graphical.target
export const FIRST_BOOT_SERVICE = 'custom-first-boot';
export const SATELLITE_SERVICE_DATA = btoa(`[Unit]
Description=Custom first boot script
ConditionFileIsExecutable=/usr/local/sbin/register-satellite
ConditionPathExists=!/var/local/.register-satellite-done
Wants=network-online.target
After=network-online.target
After=osbuild-first-boot.service
Description=Register satellite first boot script
ConditionFileIsExecutable=/usr/local/sbin/register-satellite
ConditionPathExists=!/var/local/.register-satellite-done
Wants=network-online.target
After=network-online.target
After=osbuild-first-boot.service
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/register-satellite
ExecStartPost=/usr/bin/touch /var/local/.register-satellite-done
RemainAfterExit=yes
[Service]
Type=oneshot
ExecStart=/bin/bash -x /usr/local/sbin/register-satellite
ExecStartPost=/usr/bin/touch /var/local/.register-satellite-done
RemainAfterExit=yes
[Install]
WantedBy=basic.target
WantedBy=multi-user.target
WantedBy=graphical.target
[Install]
WantedBy=basic.target
WantedBy=multi-user.target
WantedBy=graphical.target
`);
export const SATELLITE_SERVICE = 'register-satellite';