1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 08:40:09 +01:00

Adding uninstallLoopback.

This commit is contained in:
Mikaël Popowicz
2021-02-24 00:27:13 +01:00
parent 2f6dc53e2d
commit 5f46ac4e23
2 changed files with 76 additions and 22 deletions

View File

@@ -330,6 +330,10 @@ function pruneLinks()
/** /**
* Resecure all currently secured sites with a fresh configuration. * Resecure all currently secured sites with a fresh configuration.
* *
* There are only two supported values: tld and loopback
* And those must be submitted in pairs else unexpected results may occur.
* eg: both $old and $new should contain the same indexes.
*
* @param array $old * @param array $old
* @param array $new * @param array $new
* @return void * @return void
@@ -765,22 +769,44 @@ function proxyDelete($url)
function aliasLoopback($oldLoopback, $loopback) function aliasLoopback($oldLoopback, $loopback)
{ {
if ($oldLoopback !== VALET_LOOPBACK) { if ($oldLoopback !== VALET_LOOPBACK) {
$this->cli->run(sprintf( $this->removeLoopbackAlias($oldLoopback);
'sudo ifconfig lo0 -alias %s', $oldLoopback
));
info('Old loopback interface alias removed ['.$oldLoopback.']');
} }
if ($loopback !== VALET_LOOPBACK) { if ($loopback !== VALET_LOOPBACK) {
$this->cli->run(sprintf( $this->addLoopbackAlias($loopback);
'sudo ifconfig lo0 alias %s', $loopback
));
info('New loopback interface alias added ['.$loopback.']');
} }
$this->updatePlist($loopback); $this->updateLoopbackPlist($loopback);
}
/**
* Remove loopback interface alias.
*
* @param string $loopback
* @return void
*/
function removeLoopbackAlias($loopback)
{
$this->cli->run(sprintf(
'sudo ifconfig lo0 -alias %s', $loopback
));
info('['.$loopback.'] loopback interface alias removed.');
}
/**
* Remove loopback interface alias.
*
* @param string $loopback
* @return void
*/
function addLoopbackAlias($loopback)
{
$this->cli->run(sprintf(
'sudo ifconfig lo0 alias %s', $loopback
));
info('['.$loopback.'] loopback interface alias added.');
} }
/** /**
@@ -789,13 +815,9 @@ function aliasLoopback($oldLoopback, $loopback)
* @param string $loopback * @param string $loopback
* @return void * @return void
*/ */
function updatePlist($loopback) function updateLoopbackPlist($loopback)
{ {
if ($this->files->exists($this->plistPath())) { $this->removeLoopbackPlist();
$this->files->unlink($this->plistPath());
info('Old plist file removed ['.$this->plistPath().']');
}
if ($loopback !== VALET_LOOPBACK) { if ($loopback !== VALET_LOOPBACK) {
$this->files->put( $this->files->put(
@@ -807,10 +829,38 @@ function updatePlist($loopback)
) )
); );
info('New plist file added ['.$this->plistPath().']'); info('['.$this->plistPath().'] persistent loopback interface alias launch daemon added.');
} }
} }
/**
* Remove loopback interface alias launch daemon plist file.
*
* @return void
*/
function removeLoopbackPlist()
{
if ($this->files->exists($this->plistPath())) {
$this->files->unlink($this->plistPath());
info('['.$this->plistPath().'] persistent loopback interface alias launch daemon removed.');
}
}
/**
* Remove loopback interface alias and launch daemon plist file for uninstall purpose.
*
* @return void
*/
function uninstallLoopback()
{
if (($loopback = $this->valetLoopback()) !== VALET_LOOPBACK) {
$this->removeLoopbackAlias($loopback);
}
$this->removeLoopbackPlist();
}
function valetHomePath() function valetHomePath()
{ {
return VALET_HOME_PATH; return VALET_HOME_PATH;
@@ -824,8 +874,11 @@ function valetLoopback()
/** /**
* Get the path to loopback LaunchDaemon. * Get the path to loopback LaunchDaemon.
* *
* @return * @return string
return '/Library/LaunchDaemons.plist'; */
function plistPath()
{
return '/Library/LaunchDaemons/com.laravel.valet.loopback.plist';
} }
/** /**

View File

@@ -102,8 +102,7 @@
} }
if (filter_var($loopback, FILTER_VALIDATE_IP) === false) { if (filter_var($loopback, FILTER_VALIDATE_IP) === false) {
warning('['.$loopback.'] is not a valid IP address'); return warning('['.$loopback.'] is not a valid IP address');
return 1;
} }
$oldLoopback = Configuration::read()['loopback']; $oldLoopback = Configuration::read()['loopback'];
@@ -383,6 +382,8 @@
Nginx::uninstall(); Nginx::uninstall();
info('Removing Dnsmasq and configs...'); info('Removing Dnsmasq and configs...');
DnsMasq::uninstall(); DnsMasq::uninstall();
info('Removing loopback customization...');
Site::uninstallLoopback();
info('Removing Valet configs and customizations...'); info('Removing Valet configs and customizations...');
Configuration::uninstall(); Configuration::uninstall();
info('Removing PHP versions and configs...'); info('Removing PHP versions and configs...');