Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
add xon and xoff
Browse files Browse the repository at this point in the history
Signed-off-by: Jason McCallister <jason@craftcms.com>
  • Loading branch information
jasonmccallister committed Mar 4, 2020
1 parent 60cfc30 commit 59c53c6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/nitro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func run(args []string) {
host.Command(),
attach.Command(),
ssh.Command(e),
xdebug.CommandOn(),
xdebug.CommandOff(),
xdebug.CommandOn(e),
xdebug.CommandOff(e),
start.Command(),
stop.Command(),
delete.Command(),
Expand Down
28 changes: 20 additions & 8 deletions internal/initialize/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ write_files:
#!/usr/bin/env bash
sudo apt update -y && sudo apt upgrade -y
permissions: '770'
- path: /opt/nitro/php/enable-xdebug.sh
content: |
#!/bin/bash
export phpversion=$(cat /opt/nitro/php_version)
sudo phpenmod -v "$phpverison" xdebug
echo "enabled xdebug for $phpversion"
- path: /opt/nitro/php/disable-xdebug.sh
content: |
#!/bin/bash
export phpversion=$(cat /opt/nitro/php_version)
sudo phpdismod -v "$phpverison" xdebug
echo "disabled xdebug for $phpversion"
# create the php install scripts
- path: /opt/nitro/php/php-74.sh
content: |
Expand Down Expand Up @@ -92,14 +104,14 @@ write_files:
systemctl start mariadb
# create the database and user
if [ -f /home/ubuntu/.db_password ]; then
if [ -f /opt/nitro/db_password ]; then
# read the file contents for the password
export DB_USER_PASS=$(cat /home/ubuntu/.db_password)
export DB_USER_PASS=$(cat /opt/nitro/db_password)
else
# create a random password and store it
export USER_PASS=$(openssl rand -base64 16)
echo "$USER_PASS" > /home/ubuntu/.db_password
export DB_USER_PASS=$(cat /home/ubuntu/.db_password)
echo "$USER_PASS" > /opt/nitro/db_password
export DB_USER_PASS=$(cat /opt/nitro/db_password)
fi
sudo sed -i 's|CHANGEME|'$DB_USER_PASS'|g' /opt/nitro/mariadb/init.sql
Expand All @@ -118,14 +130,14 @@ write_files:
sudo service postgresql restart
# create the database and user
if [ -f /home/ubuntu/.db_password ]; then
if [ -f /opt/nitro/db_password ]; then
# read the file contents for the password
export DB_USER_PASS=$(cat /home/ubuntu/.db_password)
export DB_USER_PASS=$(cat /opt/nitro/db_password)
else
# create a random password and store it
export USER_PASS=$(openssl rand -base64 16)
echo "$USER_PASS" > /home/ubuntu/.db_password
export DB_USER_PASS=$(cat /home/ubuntu/.db_password)
echo "$USER_PASS" > /opt/nitro/db_password
export DB_USER_PASS=$(cat /opt/nitro/db_password)
fi
sudo sed -i 's|CHANGEME|'$DB_USER_PASS'|g' /opt/nitro/postgres/init.sql
Expand Down
2 changes: 1 addition & 1 deletion internal/password/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ func Command(e executor.Executor) *cli.Command {
}

func run(c *cli.Context, e executor.Executor) error {
return e.Exec(e.Path(), []string{"multipass", "exec", c.String("machine"), "--", "cat", "/home/ubuntu/.db_password"}, os.Environ())
return e.Exec(e.Path(), []string{"multipass", "exec", c.String("machine"), "--", "cat", "/opt/nitro/db_password"}, os.Environ())
}
12 changes: 7 additions & 5 deletions internal/xdebug/xdebug.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
package xdebug

import (
"errors"
"os"

"github.com/urfave/cli/v2"

"github.com/craftcms/nitro/internal/executor"
)

func CommandOn() *cli.Command {
func CommandOn(e executor.Executor) *cli.Command {
return &cli.Command{
Name: "xon",
Usage: "Enable Xdebug",
Description: "Enable Xdebug for machine",
Action: func(c *cli.Context) error {
return errors.New("not implemented")
return e.Exec(e.Path(), []string{"multipass", "exec", c.String("machine"), "--", "sudo", "bash", "/opt/nitro/php/enable-xdebug.sh"}, os.Environ())
},
}
}

func CommandOff() *cli.Command {
func CommandOff(e executor.Executor) *cli.Command {
return &cli.Command{
Name: "xoff",
Usage: "Disable Xdebug",
Description: "Disable Xdebug on machine",
Action: func(c *cli.Context) error {
return errors.New("not implemented")
return e.Exec(e.Path(), []string{"multipass", "exec", c.String("machine"), "--", "sudo", "bash", "/opt/nitro/php/disable-xdebug.sh"}, os.Environ())
},
}
}

0 comments on commit 59c53c6

Please # to comment.