@@ -22,6 +22,7 @@ public function __construct() {
2222 $ hcpp ->add_action ( 'priv_unsuspend_domain ' , [ $ this , 'priv_unsuspend_domain ' ] );
2323 $ hcpp ->add_action ( 'hcpp_plugin_installed ' , [ $ this , 'hcpp_plugin_installed ' ] );
2424 $ hcpp ->add_action ( 'hcpp_new_domain_ready ' , [ $ this , 'hcpp_new_domain_ready ' ] );
25+ $ hcpp ->add_action ( 'hcpp_rebooted ' , [ $ this , 'hcpp_rebooted ' ] );
2526 }
2627
2728 // Set MAILCATCHER_DOMAIN for PM2 started processes
@@ -71,11 +72,21 @@ public function setup( $user, $domain ) {
7172 }else {
7273 $ hcpp ->log ( 'Warning: /usr/local/hestia/data/hcpp/ports/system.ports not found ' );
7374 }
75+ $ this ->start ();
76+ }
7477
75- // Start mailcatcher if not started
78+ // Start mailcatcher
79+ public function start () {
7680 $ cmd = 'if ! runuser -s /bin/bash -l "mailcatcher" -c "cd /opt/mailcatcher && export NVM_DIR=/opt/nvm && source /opt/nvm/nvm.sh && pm2 list" | grep -q "mailcatcher_app"; ' ;
7781 $ cmd .= 'then runuser -s /bin/bash -l "mailcatcher" -c "cd /opt/mailcatcher && export NVM_DIR=/opt/nvm && source /opt/nvm/nvm.sh ; pm2 start mailcatcher.config.js"; fi ' ;
78- shell_exec ( $ cmd );
82+ global $ hcpp ;
83+ $ cmd = $ hcpp ->do_action ( 'mailcatcher_start ' , $ cmd );
84+ $ hcpp ->log ( shell_exec ( $ cmd ) );
85+ }
86+
87+ // Start mailcatcher on reboot
88+ public function hcpp_rebooted () {
89+ $ this ->start ();
7990 }
8091
8192 public function priv_unsuspend_domain ( $ args ) {
@@ -102,60 +113,60 @@ public function hcpp_render_page( $args ) {
102113 $ args = $ this ->render_edit_web ( $ args );
103114 }
104115 return $ args ;
105- }
116+ }
106117
107- // Add MailCatcher button to our web domain edit page.
108- public function render_edit_web ( $ args ) {
109- global $ hcpp ;
110- $ domain = $ _GET ['domain ' ];
111- $ content = $ args ['content ' ];
112-
113- // Create white envelope icon button to appear before Quick Installer button
114- $ code = '<a href="https:// ' . $ domain . '/mailcatcher" target="_blank" class="button button-secondary ui-button cancel" ' ;
115- $ code .= 'dir="ltr"><i class="fas fa-envelope status-icon highlight"> ' ;
116- $ code .= '</i> MailCatcher</a> ' ;
117-
118- // Inject the button into the page's toolbar buttonstrip
119- $ quick = '"fas fa-magic status-icon blue ' ; // HestiaCP 1.6.X
120- if ( strpos ( $ content , $ quick ) === false ) {
121- $ quick = '"fas fa-magic icon-blue ' ; // HestiaCP 1.7.X
122- }
123- $ before = $ hcpp ->getLeftMost ( $ content , $ quick );
124- $ after = $ quick . $ hcpp ->delLeftMost ( $ content , $ quick );
125- $ after = '<a href ' . $ hcpp ->getRightMost ( $ before , '<a href ' ) . $ after ;
126- $ before = $ hcpp ->delRightMost ( $ before , '<a href ' );
127- $ content = $ before . $ code . $ after ;
128- $ args ['content ' ] = $ content ;
129- return $ args ;
130- }
118+ // Add MailCatcher button to our web domain edit page.
119+ public function render_edit_web ( $ args ) {
120+ global $ hcpp ;
121+ $ domain = $ _GET ['domain ' ];
122+ $ content = $ args ['content ' ];
123+
124+ // Create white envelope icon button to appear before Quick Installer button
125+ $ code = '<a href="https:// ' . $ domain . '/mailcatcher" target="_blank" class="button button-secondary ui-button cancel" ' ;
126+ $ code .= 'dir="ltr"><i class="fas fa-envelope status-icon highlight"> ' ;
127+ $ code .= '</i> MailCatcher</a> ' ;
128+
129+ // Inject the button into the page's toolbar buttonstrip
130+ $ quick = '"fas fa-magic status-icon blue ' ; // HestiaCP 1.6.X
131+ if ( strpos ( $ content , $ quick ) === false ) {
132+ $ quick = '"fas fa-magic icon-blue ' ; // HestiaCP 1.7.X
133+ }
134+ $ before = $ hcpp ->getLeftMost ( $ content , $ quick );
135+ $ after = $ quick . $ hcpp ->delLeftMost ( $ content , $ quick );
136+ $ after = '<a href ' . $ hcpp ->getRightMost ( $ before , '<a href ' ) . $ after ;
137+ $ before = $ hcpp ->delRightMost ( $ before , '<a href ' );
138+ $ content = $ before . $ code . $ after ;
139+ $ args ['content ' ] = $ content ;
140+ return $ args ;
141+ }
131142
132- // Add MailCatcher icon to our web domain list page.
133- public function render_list_web ( $ args ) {
134- global $ hcpp ;
135- $ content = $ args ['content ' ];
136-
137- // Create white envelope icon before pencil/edit icon
138- $ div = '<li class="units-table-row-action shortcut-enter" data-key-action="href"> ' ;
139- $ code = '<li class="units-table-row-action" data-key-action="href">
140- <a class="units-table-row-action-link" href="https://%domain%/mailcatcher" target="_blank" title="Open MailCatcher">
141- <i class="fas fa-envelope mailcatcher"></i>
142- <span class="u-hide-desktop">MailCatcher</span>
143- </a>
144- </li> ' ;
145- $ new = '' ;
146-
147- // Inject the envelope icon for each domain
148- while ( false !== strpos ( $ content , $ div ) ) {
149- $ new .= $ hcpp ->getLeftMost ( $ content , $ div );
150- $ content = $ hcpp ->delLeftMost ( $ content , $ div );
151- $ domain = $ hcpp ->getLeftMost ( $ hcpp ->delLeftMost ( $ content , '?domain= ' ), '& ' );
152- $ new .= str_replace ( '%domain% ' , $ domain , $ code ) . $ div ;
153- }
154- $ new .= $ content ;
155- $ new .= '<style>i.mailcatcher:hover{color: white;}</style> ' ;
156- $ args ['content ' ] = $ new ;
157- return $ args ;
158- }
143+ // Add MailCatcher icon to our web domain list page.
144+ public function render_list_web ( $ args ) {
145+ global $ hcpp ;
146+ $ content = $ args ['content ' ];
147+
148+ // Create white envelope icon before pencil/edit icon
149+ $ div = '<li class="units-table-row-action shortcut-enter" data-key-action="href"> ' ;
150+ $ code = '<li class="units-table-row-action" data-key-action="href">
151+ <a class="units-table-row-action-link" href="https://%domain%/mailcatcher" target="_blank" title="Open MailCatcher">
152+ <i class="fas fa-envelope mailcatcher"></i>
153+ <span class="u-hide-desktop">MailCatcher</span>
154+ </a>
155+ </li> ' ;
156+ $ new = '' ;
157+
158+ // Inject the envelope icon for each domain
159+ while ( false !== strpos ( $ content , $ div ) ) {
160+ $ new .= $ hcpp ->getLeftMost ( $ content , $ div );
161+ $ content = $ hcpp ->delLeftMost ( $ content , $ div );
162+ $ domain = $ hcpp ->getLeftMost ( $ hcpp ->delLeftMost ( $ content , '?domain= ' ), '& ' );
163+ $ new .= str_replace ( '%domain% ' , $ domain , $ code ) . $ div ;
164+ }
165+ $ new .= $ content ;
166+ $ new .= '<style>i.mailcatcher:hover{color: white;}</style> ' ;
167+ $ args ['content ' ] = $ new ;
168+ return $ args ;
169+ }
159170
160171 // Allocate port on install
161172 public function hcpp_plugin_installed ( $ plugin_name ) {
0 commit comments