mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 00:40:06 +01:00
✨ Adding uninstallLoopback.
This commit is contained in:
@@ -330,6 +330,10 @@ function pruneLinks()
|
||||
/**
|
||||
* 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 $new
|
||||
* @return void
|
||||
@@ -765,22 +769,44 @@ function proxyDelete($url)
|
||||
function aliasLoopback($oldLoopback, $loopback)
|
||||
{
|
||||
if ($oldLoopback !== VALET_LOOPBACK) {
|
||||
$this->cli->run(sprintf(
|
||||
'sudo ifconfig lo0 -alias %s', $oldLoopback
|
||||
));
|
||||
|
||||
info('Old loopback interface alias removed ['.$oldLoopback.']');
|
||||
$this->removeLoopbackAlias($oldLoopback);
|
||||
}
|
||||
|
||||
if ($loopback !== VALET_LOOPBACK) {
|
||||
$this->addLoopbackAlias($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('New loopback interface alias added ['.$loopback.']');
|
||||
}
|
||||
|
||||
$this->updatePlist($loopback);
|
||||
info('['.$loopback.'] loopback interface alias added.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -789,13 +815,9 @@ function aliasLoopback($oldLoopback, $loopback)
|
||||
* @param string $loopback
|
||||
* @return void
|
||||
*/
|
||||
function updatePlist($loopback)
|
||||
function updateLoopbackPlist($loopback)
|
||||
{
|
||||
if ($this->files->exists($this->plistPath())) {
|
||||
$this->files->unlink($this->plistPath());
|
||||
|
||||
info('Old plist file removed ['.$this->plistPath().']');
|
||||
}
|
||||
$this->removeLoopbackPlist();
|
||||
|
||||
if ($loopback !== VALET_LOOPBACK) {
|
||||
$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()
|
||||
{
|
||||
return VALET_HOME_PATH;
|
||||
@@ -824,8 +874,11 @@ function valetLoopback()
|
||||
/**
|
||||
* Get the path to loopback LaunchDaemon.
|
||||
*
|
||||
* @return
|
||||
return '/Library/LaunchDaemons.plist';
|
||||
* @return string
|
||||
*/
|
||||
function plistPath()
|
||||
{
|
||||
return '/Library/LaunchDaemons/com.laravel.valet.loopback.plist';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,8 +102,7 @@
|
||||
}
|
||||
|
||||
if (filter_var($loopback, FILTER_VALIDATE_IP) === false) {
|
||||
warning('['.$loopback.'] is not a valid IP address');
|
||||
return 1;
|
||||
return warning('['.$loopback.'] is not a valid IP address');
|
||||
}
|
||||
|
||||
$oldLoopback = Configuration::read()['loopback'];
|
||||
@@ -383,6 +382,8 @@
|
||||
Nginx::uninstall();
|
||||
info('Removing Dnsmasq and configs...');
|
||||
DnsMasq::uninstall();
|
||||
info('Removing loopback customization...');
|
||||
Site::uninstallLoopback();
|
||||
info('Removing Valet configs and customizations...');
|
||||
Configuration::uninstall();
|
||||
info('Removing PHP versions and configs...');
|
||||
|
||||
Reference in New Issue
Block a user