Make wsl-setup a script
The script generates wsl-distribution.conf from a template. You can pass it options for the Name as well as the logo file. Signed-off-by: Troy Dawson <tdawson@redhat.com>
This commit is contained in:
parent
3c2b79527f
commit
b781149120
@ -20,4 +20,4 @@ defaultName = DEFAULT_NAME
|
||||
|
||||
[shortcut]
|
||||
enabled = true
|
||||
icon = /usr/share/pixmaps/fedora-logo.ico
|
||||
icon = DEFAULT_ICON_FULL_PATH
|
||||
|
86
wsl-setup
Executable file
86
wsl-setup
Executable file
@ -0,0 +1,86 @@
|
||||
#!/usr/bin/bash
|
||||
#
|
||||
# Setup the environment for the new WSL configuration
|
||||
#
|
||||
# Copyright (C) 2025
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# Authors:
|
||||
# Troy Dawson <tdawson@redhat.com>
|
||||
#
|
||||
|
||||
###############
|
||||
# Variables
|
||||
###############
|
||||
DISTRIBUTION_TEMPLATE_FILE="/usr/share/wsl-setup/wsl-distribution.conf.template"
|
||||
DISTRIBUTION_CONF_FILE="/usr/lib/wsl-distribution.conf"
|
||||
DISTRIBUTION_CONF_LINK="/etc/wsl-distribution.conf"
|
||||
. /etc/os-release
|
||||
DEFAULT_NAME="${NAME// /}-${VERSION_ID%.*}"
|
||||
ICON_PATH="/usr/share/pixmaps/fedora-logo.ico"
|
||||
|
||||
###############
|
||||
# Show help
|
||||
###############
|
||||
usage() {
|
||||
echo "Usage `basename $0` <options> " >&2
|
||||
echo >&2
|
||||
echo "Setup the environment for the new WSL configuration" >&2
|
||||
echo >&2
|
||||
echo "Options:" >&2
|
||||
echo " --name, -n" >&2
|
||||
echo " Set the distro name" >&2
|
||||
echo " Default: ${DEFAULT_NAME}" >&2
|
||||
echo " --icon, -i" >&2
|
||||
echo " Full pathname to the icon" >&2
|
||||
echo " Default: ${ICON_PATH}" >&2
|
||||
echo " --help, -h" >&2
|
||||
echo " Show this options menu" >&2
|
||||
echo >&2
|
||||
popd &>/dev/null
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
###############
|
||||
# Get our arguments
|
||||
###############
|
||||
while [[ "$#" -ge 1 ]]
|
||||
do
|
||||
key="$1"
|
||||
case $key in
|
||||
--name | -n )
|
||||
if ! [ "${2}" == "" ] ; then
|
||||
DEFAULT_NAME="${2}"
|
||||
shift
|
||||
else
|
||||
echo "ERROR: Name is not provided"
|
||||
echo
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
--icon | -i )
|
||||
if ! [ "${2}" == "" ] ; then
|
||||
ICON_PATH="${2}"
|
||||
shift
|
||||
else
|
||||
echo "ERROR: Icon full path is not provided"
|
||||
echo
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
###############
|
||||
# Do the work
|
||||
###############
|
||||
|
||||
cp -f ${DISTRIBUTION_TEMPLATE_FILE} ${DISTRIBUTION_CONF_FILE}
|
||||
sed -i -e "s|DEFAULT_NAME|${DEFAULT_NAME}|" -e "s|DEFAULT_ICON_FULL_PATH|${ICON_PATH}|" ${DISTRIBUTION_CONF_FILE}
|
@ -1,5 +1,5 @@
|
||||
Name: wsl-setup
|
||||
Version: 1.0.0
|
||||
Version: 1.0.1
|
||||
Release: %autorelease
|
||||
Summary: Windows Subsystem for Linux setup script and configuration
|
||||
License: MIT
|
||||
@ -13,6 +13,7 @@ Source4: wsl-oobe.sh
|
||||
Source5: firstboot-override.conf
|
||||
Source6: wsl-setup-tmpfiles.conf
|
||||
Source7: wsl-setup-user-tmpfiles.conf
|
||||
Source8: wsl-setup
|
||||
|
||||
BuildRequires: systemd-rpm-macros
|
||||
|
||||
@ -34,7 +35,9 @@ Provides WSL specific configuration files and first-time setup script.
|
||||
install -pm 0644 %{SOURCE1} LICENSE
|
||||
install -Dpm0644 -t %{buildroot}%{_sysconfdir}/ %{SOURCE2}
|
||||
install -Dpm0644 -t %{buildroot}%{_prefix}/lib/ %{SOURCE3}
|
||||
install -Dpm0644 -T %{SOURCE3} %{buildroot}%{_datarootdir}/wsl-setup/wsl-distribution.conf.template
|
||||
install -Dpm0755 -T %{SOURCE4} %{buildroot}%{_libexecdir}/wsl/oobe.sh
|
||||
install -Dpm0755 -T %{SOURCE8} %{buildroot}%{_bindir}/wsl-setup
|
||||
ln -s ..%{_prefix}/lib/wsl-distribution.conf %{buildroot}%{_sysconfdir}/wsl-distribution.conf
|
||||
|
||||
# WSL provides a socket for x11, but we need to ensure its linked to in /tmp.
|
||||
@ -55,16 +58,17 @@ install -Dpm0644 %{SOURCE5} %{buildroot}%{_unitdir}/systemd-firstboot.service.d/
|
||||
|
||||
|
||||
%post
|
||||
# generate the "auto" naming
|
||||
. %{_sysconfdir}/os-release
|
||||
DYNAMIC_NAME="${NAME// /}-${VERSION_ID%.*}"
|
||||
sed -i "s,DEFAULT_NAME,${DYNAMIC_NAME}," %{_sysconfdir}/wsl-distribution.conf
|
||||
# generate the "auto" naming, using the defaults
|
||||
%{_bindir}/wsl-setup
|
||||
|
||||
|
||||
%files
|
||||
%{_bindir}/wsl-setup
|
||||
%config(noreplace) %{_sysconfdir}/wsl.conf
|
||||
%{_prefix}/lib/wsl-distribution.conf
|
||||
%{_sysconfdir}/wsl-distribution.conf
|
||||
%dir %{_datarootdir}/wsl-setup/
|
||||
%{_datarootdir}/wsl-setup/wsl-distribution.conf.template
|
||||
%{_libexecdir}/wsl/oobe.sh
|
||||
%{_tmpfilesdir}/%{name}.conf
|
||||
%{_user_tmpfilesdir}/%{name}.conf
|
||||
|
Loading…
Reference in New Issue
Block a user