Initial import (rhbz #2342289)
This commit is contained in:
parent
148a880fb5
commit
7fee63c813
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright 2025 Fedora Project Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
wsl-distribution.conf
Normal file
19
wsl-distribution.conf
Normal file
@ -0,0 +1,19 @@
|
||||
# The /etc/wsl-distribution.conf configuration file.
|
||||
#
|
||||
# This is not intended to be edited by users; it is how WSL discovers
|
||||
# distribution defaults.
|
||||
#
|
||||
# Available configuration options are documented at
|
||||
# https://learn.microsoft.com/en-us/windows/wsl/build-custom-distro
|
||||
|
||||
[oobe]
|
||||
# Command run the first time the user opens an interactive shell.
|
||||
# If the command returns non-zero, it is considered unsuccessful and the
|
||||
# user won't be able to open a shell.
|
||||
command = /usr/libexec/wsl/oobe.sh
|
||||
# Default UID for user the distribution starts with.
|
||||
defaultUid = 1000
|
||||
# Default name the distribution is registered under.
|
||||
# This is used when the user double-clicks to install, or uses
|
||||
# wsl --install --from-file ./Fedora.wsl
|
||||
defaultName = $NAME
|
38
wsl-oobe.sh
Normal file
38
wsl-oobe.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The Fedora WSL out of box experience script.
|
||||
#
|
||||
# This command runs the first time the user opens an interactive shell.
|
||||
#
|
||||
# A non-zero exit code indicates to WSL that setup failed.
|
||||
|
||||
set -ueo pipefail
|
||||
|
||||
DEFAULT_USER_ID=1000
|
||||
|
||||
echo 'Please create a default user account. The username does not need to match your Windows username.'
|
||||
echo 'For more information visit: https://aka.ms/wslusers'
|
||||
|
||||
if getent passwd $DEFAULT_USER_ID > /dev/null ; then
|
||||
echo 'User account already exists, skipping creation'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prompt from the username
|
||||
read -r -p 'Enter new UNIX username: ' username
|
||||
|
||||
# Create the user
|
||||
/usr/sbin/useradd -m -G wheel --uid $DEFAULT_USER_ID "$username"
|
||||
|
||||
cat > /etc/sudoers.d/wsluser << EOF
|
||||
# Ensure the WSL initial user can use sudo
|
||||
$username ALL=(ALL) NOPASSWD: ALL
|
||||
EOF
|
||||
|
||||
# Set the default user; necessary when this script is manually run in versions
|
||||
# of WSL prior to 2.4.
|
||||
cat >> /etc/wsl.conf << EOF
|
||||
|
||||
[user]
|
||||
default = "$username"
|
||||
EOF
|
58
wsl-setup.spec
Normal file
58
wsl-setup.spec
Normal file
@ -0,0 +1,58 @@
|
||||
%if 0%{?eln}
|
||||
%define default_name ELN
|
||||
%else
|
||||
%define default_name Fedora
|
||||
%endif
|
||||
|
||||
|
||||
Name: wsl-setup
|
||||
Version: 1.0.0
|
||||
Release: %autorelease
|
||||
Summary: Windows Subsystem for Linux setup script and configuration
|
||||
License: MIT
|
||||
URL: https://src.fedoraproject.org/rpms/wsl-setup
|
||||
BuildArch: noarch
|
||||
|
||||
Source1: LICENSE
|
||||
Source2: wsl.conf
|
||||
Source3: wsl-distribution.conf
|
||||
Source4: wsl-oobe.sh
|
||||
|
||||
|
||||
%description
|
||||
Provides WSL specific configuration files and first-time setup script.
|
||||
|
||||
|
||||
%prep
|
||||
%if 0%{?fedora}
|
||||
sed -i 's,$NAME,Fedora,' %{SOURCE3}
|
||||
%else
|
||||
sed -i 's,$NAME,ELN,' %{SOURCE3}
|
||||
%endif
|
||||
|
||||
|
||||
%build
|
||||
|
||||
|
||||
%install
|
||||
install -pm 0644 %{SOURCE1} LICENSE
|
||||
install -Dpm0644 -t %{buildroot}%{_sysconfdir}/ %{SOURCE2}
|
||||
install -Dpm0644 -t %{buildroot}%{_prefix}/lib/ %{SOURCE3}
|
||||
install -Dpm0755 -T %{SOURCE4} %{buildroot}%{_libexecdir}/wsl/oobe.sh
|
||||
ln -s ..%{_prefix}/lib/wsl-distribution.conf %{buildroot}%{_sysconfdir}/wsl-distribution.conf
|
||||
|
||||
|
||||
%check
|
||||
grep "defaultName = %{default_name}" %{buildroot}%{_sysconfdir}/wsl-distribution.conf
|
||||
|
||||
|
||||
%files
|
||||
%config(noreplace) %{_sysconfdir}/wsl.conf
|
||||
%{_prefix}/lib/wsl-distribution.conf
|
||||
%{_sysconfdir}/wsl-distribution.conf
|
||||
%{_libexecdir}/wsl/oobe.sh
|
||||
%license LICENSE
|
||||
|
||||
|
||||
%changelog
|
||||
%autochangelog
|
Loading…
Reference in New Issue
Block a user