Automatic trigger enabling of Openresty during WSL (Windows Subsystem of Linux) startup in Windows 2022 Server

Automatic trigger enabling of Openresty during WSL (Windows Subsystem of Linux) startup in Windows 2022 Server

Step 1: Login as Sudo user in WSL and Install the below package first


sudo apt install expect
    

Step 2: Create the shell script as below


nano start_openresty_expect.sh

#!/usr/bin/expect -f

set timeout 10
spawn sudo service openresty start
expect "password for jegan:"
send "jegan@123\r"
expect eof
    

Step 3: Provide executable permission to the shell script start_openresty_expect.sh


chmod +x start_openresty_expect.sh
    

Step 4: Go to bashrc file


nano ~/.bashrc
    

Step 5: Add the below at the end of the bashrc file, then save and exit


~/start_openresty_expect.sh
    

Step 6: Update bashrc


source ~/.bashrc
    

Whenever the WSL restarts/reboots/starts Openresty will be automatically enabled.

Comments

Popular posts from this blog

MongoDB Installation Ubuntu 22.04 LTS