Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ISPConfig 3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
brody
ISPConfig 3
Commits
ea9f8ef6
Commit
ea9f8ef6
authored
Nov 05, 2018
by
Till Brehm
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'master'
Add website_symlink_plugin.inc.php See merge request
!838
parents
0281760d
f9626973
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
server/plugins-available/website_symlink_plugin.inc.php
server/plugins-available/website_symlink_plugin.inc.php
+80
-0
No files found.
server/plugins-available/website_symlink_plugin.inc.php
0 → 100644
View file @
ea9f8ef6
<?php
/**
* When installed, this plugin will create a relative symlink from $HOME/website to /web when:
* - domain is created or updated
* - shell user is created or updated
*
* Its purpose is to make it easier for users to navigate to their web folder. If a file named website/ already exists
* it is not overwritten.
*
* Example:
*
* $ ls -al /var/www/domain.com/home/username
* total 12
* drwxr-x--- 3 web1 client1 4096 Nov 4 22:19 .
* drwxr-xr-x 4 root root 4096 Nov 4 22:19 ..
* lrwxrwxrwx 1 root root 9 Nov 4 22:19 website -> ../../web
*/
class
website_symlink_plugin
{
var
$plugin_name
=
'website_symlink_plugin'
;
var
$class_name
=
'website_symlink_plugin'
;
public
function
onInstall
()
{
global
$conf
;
// Enable the following code section to activate the plugin automatically at install time
/*
if ($conf['services']['web'] == true) {
return true;
}
*/
return
false
;
}
public
function
onLoad
()
{
global
$app
;
$app
->
plugins
->
registerEvent
(
'web_domain_insert'
,
$this
->
plugin_name
,
'createSymlinkForWebDomain'
);
$app
->
plugins
->
registerEvent
(
'web_domain_update'
,
$this
->
plugin_name
,
'createSymlinkForWebDomain'
);
$app
->
plugins
->
registerEvent
(
'shell_user_insert'
,
$this
->
plugin_name
,
'createSymlinkForShellUser'
);
$app
->
plugins
->
registerEvent
(
'shell_user_update'
,
$this
->
plugin_name
,
'createSymlinkForShellUser'
);
}
public
function
createSymlinkForWebDomain
(
$event_name
,
$data
)
{
$homeDirectories
=
glob
(
sprintf
(
'%s/home'
,
$data
[
'new'
][
'document_root'
])
.
'/*'
,
GLOB_ONLYDIR
);
foreach
(
$homeDirectories
as
$dir
)
{
$target
=
sprintf
(
'%s/web'
,
$data
[
'new'
][
'document_root'
]);
$link
=
sprintf
(
'%s/website'
,
$dir
);
$this
->
createSymlink
(
$target
,
$link
);
}
}
public
function
createSymlinkForShellUser
(
$event_name
,
$data
)
{
$target
=
sprintf
(
'%s/web'
,
$data
[
'new'
][
'dir'
]);
$link
=
sprintf
(
'%s/home/%s/website'
,
$data
[
'new'
][
'dir'
],
$data
[
'new'
][
'username'
]);
$this
->
createSymlink
(
$target
,
$link
);
}
private
function
createSymlink
(
$target
,
$link
)
{
global
$app
;
if
(
file_exists
(
$link
))
{
$app
->
log
(
sprintf
(
'Not creating symlink because "%s" already exists'
,
$link
),
LOGLEVEL_DEBUG
);
return
;
}
if
(
$app
->
system
->
create_relative_link
(
$target
,
$link
))
{
$app
->
log
(
sprintf
(
'Created symlink from "%s" to "%s"'
,
$link
,
$target
),
LOGLEVEL_DEBUG
);
}
else
{
$app
->
log
(
sprintf
(
'Failed to create symlink from "%s" to "%s"'
,
$link
,
$target
),
LOGLEVEL_WARN
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment