homestead icon indicating copy to clipboard operation
homestead copied to clipboard

WSL Installation Upgrades and Documentation

Open karmendra opened this issue 11 months ago • 5 comments

  • bin/homestead
    • Registered WslApplyFolderMapping command
  • scripts\features\mariadb.sh
    • Stop the mysql service before uninstall and remove the installation tracking file.
  • scripts\features\mysql.sh
    • Create feature installation script for mysql.
  • scripts\features\postgresql.sh
    • Removed systemctl disable postgresq from the end to make sure it works after the feature install
  • src\WslApplyFeatures.php
    • Changed the command name from wsl:apply-features to wsl:features.
  • src\WslApplyFolderMapping.php
    • Added new command to do folder mapping
  • src\WslCreateDatabaseCommand.php
    • Changed the command name from wsl:create-databases to wsl:databases.
  • src\WslCreateSiteCommand.php
    • Changed the command name from wsl:create-sites to wsl:sites.
    • Remove nginx/sites-enabled/* as well while removing existing nginx sites.
    • Add cron job for laravel schedule:run if mentioned in yaml file.
  • wsl.md
    • Documentation for Installing Homestead on Windows subsystem for Linux

karmendra avatar Mar 01 '24 10:03 karmendra

@svpernova09 / @MichaelBelgium , I just fixed a typo that I found in wsl.md. This PR is ready to merge, let me know if there is anything else to be addressed.

@svpernova09, I have checked php8.3.sh, there are only two environment vars (WSL_USER_NAME and WSL_USER_GROUP) and these are populated from the files storing these values.

karmendra avatar Mar 05 '24 08:03 karmendra

Looks okay for me, I don't see the benefit of the wsl:folders command tho. But I see its perhaps required due the change from wsl_sites to sites, which means the separate mapping for wsl will be gone

So this change is from, eg,

wsl_sites:
  - map: homestead.test
    to: /mnt/c/Users/<user>/Documents/code/public

to

folders:
    - map: ~/code
      to: /mnt/c/Users/<user>/Documents/code

sites:
    - map: homestead.test
      to: /mnt/c/Users/<user>/Documents/code/public

If i'm correct, the command will loop through folders and create a symlink between ~/code and /mnt/c/Users//Documents/code

Although, if someone does the config from below, the symbolic link will be useless i think?

sites:
    - map: homestead.test
      to: /mnt/c/Users/<user>/Documents/code/public

in stead of

sites:
    - map: homestead.test
      to: ~/code/public

which is the symlink

Lastly the checks you did before in wsl init, those were good, i'd keep those

if [[ $EUID -ne 0 ]]; then
    echo "Error: This script must be run as root.">&2

    exit 1
fi

# ....

# Set default
if [ -z "${WSL_USER_NAME}" ]; then
    WSL_USER_NAME=vagrant
fi
if [ -z "${WSL_USER_GROUP}" ]; then
    WSL_USER_GROUP=vagrant
fi

# Validate user and group
if ! id "$WSL_USER_NAME" &>/dev/null; then
    echo "Error: User $WSL_USER_NAME does not exist.">&2

    exit 1
fi
if ! getent group "$WSL_USER_GROUP" &>/dev/null; then
    echo "Error: Group $WSL_USER_GROUP does not exist.">&2

    exit 1
fi
if ! groups "$WSL_USER_NAME" | grep -q "\b$WSL_USER_GROUP\b"; then
    echo "Error: User $WSL_USER_NAME is not a member of group $WSL_USER_GROUP.">&2

    exit 1
fi

MichaelBelgium avatar Mar 06 '24 11:03 MichaelBelgium

My idea for wsl:folders was just to replicate the feature from vagrant. But the problem with approach of code hosted in windows and linked in ubuntu is that it is really slow to render these webpages.

Website load much faster if the code is in Ubuntu's file system. Problem here is code would be lost if wsl is unregistered, unlike the previous approach.

I will work on wsl:backup command that can easily backup the sites and database in future.

Regarding the validations, I will go ahead and add those validations in wsl-init.

Thanks.

karmendra avatar Mar 07 '24 11:03 karmendra

Giving this a review now. Sorry for the delays. I found a bug in the MariaDB installer so far. Should be good to merge this soon.

svpernova09 avatar Mar 11 '24 15:03 svpernova09

I think we want to keep the WSL config separate from the Homestead Configuration. I traditionally have a giant Homestead.yaml that gets configured and passed around various machines and configurations.

At some point this WSL stuff will need to get pulled out of Homestead because it's not really.... Homestead in the Vagrant sense.

svpernova09 avatar Mar 11 '24 16:03 svpernova09

Hi @MichaelBelgium

Lastly the checks you did before in wsl init, those were good, i'd keep those

I updated the wsl-init to add those checks.

P.S. Sorry for the delay, I was on long vacation.

karmendra avatar Mar 29 '24 04:03 karmendra

Hi @MichaelBelgium

Lastly the checks you did before in wsl init, those were good, i'd keep those

I updated the wsl-init to add those checks.

@karmendra I don't see the checks in this PR?

MichaelBelgium avatar Apr 16 '24 19:04 MichaelBelgium

@karmendra I don't see the checks in this PR?

Thanks @MichaelBelgium for checking this, I thought I have done the changes but looks like I have forgotten to push my changes. image I just pushed my changes, please have a look.

karmendra avatar Apr 20 '24 08:04 karmendra