[systemd] Relocate all SONiC unit files to /usr/lib/systemd/system (#4673)
This will allow us to disable services and have it persist across reboots by using the `systemctl mask` operation
This commit is contained in:
parent
59db60bd8e
commit
1e369b0998
@ -33,6 +33,7 @@ SCRIPTS_DIR=files/scripts
|
||||
|
||||
# Define target fold macro
|
||||
FILESYSTEM_ROOT_USR="$FILESYSTEM_ROOT/usr"
|
||||
FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM="$FILESYSTEM_ROOT/usr/lib/systemd/system"
|
||||
FILESYSTEM_ROOT_USR_SHARE="$FILESYSTEM_ROOT_USR/share"
|
||||
FILESYSTEM_ROOT_USR_SHARE_SONIC="$FILESYSTEM_ROOT_USR_SHARE/sonic"
|
||||
FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES="$FILESYSTEM_ROOT_USR_SHARE_SONIC/templates"
|
||||
@ -220,18 +221,18 @@ sudo chmod 600 $FILESYSTEM_ROOT/etc/monit/conf.d/*
|
||||
sudo cp -f $IMAGE_CONFIGS/cron.d/* $FILESYSTEM_ROOT/etc/cron.d/
|
||||
|
||||
# Copy NTP configuration files and templates
|
||||
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "ntp-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.sh $FILESYSTEM_ROOT/usr/bin/
|
||||
sudo cp $IMAGE_CONFIGS/ntp/ntp.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
||||
|
||||
# Copy warmboot-finalizer files
|
||||
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/finalize-warmboot.sh $FILESYSTEM_ROOT/usr/local/bin/finalize-warmboot.sh
|
||||
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/warmboot-finalizer.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/warmboot-finalizer.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "warmboot-finalizer.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
|
||||
# Copy rsyslog configuration files and templates
|
||||
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/
|
||||
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
||||
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/
|
||||
@ -249,7 +250,7 @@ sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate
|
||||
sudo cp -f $IMAGE_CONFIGS/systemd/journald.conf $FILESYSTEM_ROOT/etc/systemd/
|
||||
|
||||
# Copy interfaces configuration files and templates
|
||||
sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.sh $FILESYSTEM_ROOT/usr/bin/
|
||||
sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
||||
echo "interfaces-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
@ -265,13 +266,13 @@ sudo cp $IMAGE_CONFIGS/interfaces/init_interfaces $FILESYSTEM_ROOT/etc/network/i
|
||||
sudo mkdir -p $FILESYSTEM_ROOT/etc/network/interfaces.d
|
||||
|
||||
# Copy hostcfgd files
|
||||
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "hostcfgd.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd $FILESYSTEM_ROOT/usr/bin/
|
||||
sudo cp $IMAGE_CONFIGS/hostcfgd/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
||||
|
||||
# copy core file uploader files
|
||||
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_uploader.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_uploader.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable core_uploader.service
|
||||
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_uploader.py $FILESYSTEM_ROOT/usr/bin/
|
||||
sudo cp $IMAGE_CONFIGS/corefile_uploader/core_analyzer.rc.json $FILESYSTEM_ROOT_ETC_SONIC/
|
||||
@ -296,7 +297,7 @@ sudo cp $BUILD_TEMPLATES/buffers_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMP
|
||||
sudo cp $BUILD_TEMPLATES/qos_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
||||
|
||||
# Copy hostname configuration scripts
|
||||
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "hostname-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.sh $FILESYSTEM_ROOT/usr/bin/
|
||||
|
||||
@ -305,13 +306,13 @@ sudo cp $IMAGE_CONFIGS/misc/docker-wait-any $FILESYSTEM_ROOT/usr/bin/
|
||||
|
||||
# Copy internal topology configuration scripts
|
||||
{%- if sonic_asic_platform == "vs" %}
|
||||
sudo cp $IMAGE_CONFIGS/topology/topology.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/topology/topology.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "topology.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/topology/topology.sh $FILESYSTEM_ROOT/usr/bin
|
||||
{%- endif %}
|
||||
|
||||
# Copy updategraph script and service file
|
||||
j2 files/build_templates/updategraph.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/updategraph.service
|
||||
j2 files/build_templates/updategraph.service.j2 | sudo tee $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/updategraph.service
|
||||
sudo cp $IMAGE_CONFIGS/updategraph/updategraph $FILESYSTEM_ROOT/usr/bin/
|
||||
echo "updategraph.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
{% if enable_dhcp_graph_service == "y" %}
|
||||
@ -326,7 +327,7 @@ sudo bash -c "echo enabled=false > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
||||
j2 files/build_templates/init_cfg.json.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/init_cfg.json
|
||||
|
||||
# Copy config-setup script and service file
|
||||
j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/config-setup.service
|
||||
j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/config-setup.service
|
||||
sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config-setup
|
||||
echo "config-setup.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service
|
||||
@ -342,22 +343,22 @@ sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/
|
||||
sudo cp $IMAGE_CONFIGS/sudoers/sudoers.lecture $FILESYSTEM_ROOT/etc/
|
||||
|
||||
# Copy control plane ACL management daemon files
|
||||
sudo cp $IMAGE_CONFIGS/caclmgrd/caclmgrd.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/caclmgrd/caclmgrd.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "caclmgrd.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/caclmgrd/caclmgrd $FILESYSTEM_ROOT/usr/bin/
|
||||
|
||||
# Copy process/docker cpu/memory utilization data export daemon
|
||||
sudo cp $IMAGE_CONFIGS/procdockerstatsd/procdockerstatsd.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/procdockerstatsd/procdockerstatsd.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "procdockerstatsd.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/procdockerstatsd/procdockerstatsd $FILESYSTEM_ROOT/usr/bin/
|
||||
|
||||
# Copy systemd timer configuration
|
||||
# It implements delayed start of services
|
||||
sudo cp $BUILD_TEMPLATES/process-reboot-cause.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $BUILD_TEMPLATES/process-reboot-cause.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable process-reboot-cause.timer
|
||||
|
||||
# Copy process-reboot-cause service files
|
||||
sudo cp $IMAGE_CONFIGS/process-reboot-cause/process-reboot-cause.service $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/process-reboot-cause/process-reboot-cause.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
echo "process-reboot-cause.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
sudo cp $IMAGE_CONFIGS/process-reboot-cause/process-reboot-cause $FILESYSTEM_ROOT/usr/bin/
|
||||
|
||||
@ -414,7 +415,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -P {{ debname }}
|
||||
sudo rm -f $FILESYSTEM_ROOT/usr/sbin/policy-rc.d
|
||||
|
||||
# Copy fstrim service and timer file, enable fstrim timer
|
||||
sudo cp $IMAGE_CONFIGS/fstrim/* $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $IMAGE_CONFIGS/fstrim/* $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable fstrim.timer
|
||||
|
||||
## copy platform rc.local
|
||||
@ -485,12 +486,12 @@ sudo cp {{script}} $FILESYSTEM_ROOT/usr/bin/
|
||||
{% endfor %}
|
||||
{% for service in installer_services.split(' ') -%}
|
||||
if [ -f {{service}} ]; then
|
||||
sudo cp {{service}} $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp {{service}} $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
|
||||
{% if "@" in service %}
|
||||
MULTI_INSTANCE="{{service}}"
|
||||
SINGLE_INSTANCE=${MULTI_INSTANCE/"@"}
|
||||
sudo cp $SINGLE_INSTANCE $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $SINGLE_INSTANCE $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
{% endif %}
|
||||
|
||||
echo "{{service}}" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
@ -512,10 +513,10 @@ sudo LANG=C cp $SCRIPTS_DIR/sonic-netns-exec $FILESYSTEM_ROOT/usr/bin/sonic-netn
|
||||
|
||||
# Copy systemd timer configuration
|
||||
# It implements delayed start of services
|
||||
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable snmp.timer
|
||||
{% if enable_system_telemetry == 'y' %}
|
||||
sudo cp $BUILD_TEMPLATES/telemetry.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
||||
sudo cp $BUILD_TEMPLATES/telemetry.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
|
||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable telemetry.timer
|
||||
{% endif %}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define MAX_NUM_UNITS 128
|
||||
#define MAX_BUF_SIZE 512
|
||||
|
||||
static const char* UNIT_FILE_PREFIX = "/etc/systemd/system/";
|
||||
static const char* UNIT_FILE_PREFIX = "/usr/lib/systemd/system/";
|
||||
static const char* CONFIG_FILE = "/etc/sonic/generated_services.conf";
|
||||
static const char* MACHINE_CONF_FILE = "/host/machine.conf";
|
||||
static int num_asics;
|
||||
|
Loading…
Reference in New Issue
Block a user