Skip to content

Commit

Permalink
rebrand
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveorevo committed Nov 5, 2023
1 parent bff3718 commit b8c593e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions vscode.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class VSCode {
public function __construct() {
global $hcpp;
$hcpp->webdav = $this;
$hcpp->add_action( 'cg_pws_generate_website_cert', [ $this, 'cg_pws_generate_website_cert' ] );
$hcpp->add_action( 'dev_pw_generate_website_cert', [ $this, 'dev_pw_generate_website_cert' ] );
$hcpp->add_action( 'post_change_user_shell', [ $this, 'post_change_user_shell' ] );
$hcpp->add_action( 'hcpp_invoke_plugin', [ $this, 'hcpp_invoke_plugin' ] );
$hcpp->add_action( 'post_delete_user', [ $this, 'post_delete_user' ] );
Expand Down Expand Up @@ -61,16 +61,16 @@ public function hcpp_plugin_enabled( $plugin ) {
}

// Intercept the certificate generation and copy over ssl certs for the vscode domain.
public function cg_pws_generate_website_cert( $cmd ) {
if ( strpos( $cmd, '/vscode-' ) !== false && strpos( $cmd, '/cg_pws_ssl && ') !== false ) {
public function dev_pw_generate_website_cert( $cmd ) {
if ( strpos( $cmd, '/vscode-' ) !== false && strpos( $cmd, '/dev_pw_ssl && ') !== false ) {

// Omit the v-delete-web-domain-ssl, v-add-web-domain-ssl, and v-add-web-domain-ssl-force cmds.
global $hcpp;
$path = $hcpp->delLeftMost( $cmd, '/usr/local/hestia/bin/v-add-web-domain-ssl' );
$path = '/home' . $hcpp->delLeftMost( $path, '/home' );
$path = $hcpp->delRightMost( $path, '/cg_pws_ssl &&' );
$path = $hcpp->delRightMost( $path, '/dev_pw_ssl &&' );
$cmd = $hcpp->delRightMost( $cmd, '/usr/local/hestia/bin/v-delete-web-domain-ssl ' );
$cmd .= " mkdir -p $path/ssl ; cp -r $path/cg_pws_ssl/* $path/ssl ";
$cmd .= " mkdir -p $path/ssl ; cp -r $path/dev_pw_ssl/* $path/ssl ";
$cmd = $hcpp->do_action( 'vscode_generate_website_cert', $cmd );
}
return $cmd;
Expand Down Expand Up @@ -208,8 +208,8 @@ public function setup( $user ) {
$content
);

// Uncomment basic auth for non-Personal Web Server edition.
if ( !property_exists( $hcpp, 'cg_pws' ) ) {
// Uncomment basic auth for non-Devstia Preview edition.
if ( !property_exists( $hcpp, 'dev_pw' ) ) {
$content = str_replace( "#auth_basic", "auth_basic", $content );
}
file_put_contents( $conf, $content );
Expand All @@ -223,20 +223,20 @@ public function setup( $user ) {
$content
);

// Uncomment basic auth on SSL for non-Personal Web Server edition.
if ( !property_exists( $hcpp, 'cg_pws' ) ) {
// Uncomment basic auth on SSL for non-Devstia Preview edition.
if ( !property_exists( $hcpp, 'dev_pw' ) ) {
$content = str_replace( "#auth_basic", "auth_basic", $content );
}
file_put_contents( $ssl_conf, $content );

// Generate website cert if it doesn't exist for Personal Web Server edition.
if ( property_exists( $hcpp, 'cg_pws' ) ) {
// Generate website cert if it doesn't exist for Devstia Preview edition.
if ( property_exists( $hcpp, 'dev_pw' ) ) {

// Always regenerate the cert to ensure it's up to date.
$hcpp->cg_pws->generate_website_cert( $user, ["vscode-$user.$domain"] );
$hcpp->dev_pw->generate_website_cert( $user, ["vscode-$user.$domain"] );
}else{

// Force SSL on non-Personal Web Server edition.
// Force SSL on non-Devstia Preview edition.
$force_ssl_conf = "/home/$user/conf/web/vscode-$user.$domain/nginx.forcessl.conf";
$content = "return 301 https://\$host\$request_uri;";
file_put_contents( $force_ssl_conf, $content );
Expand Down

0 comments on commit b8c593e

Please sign in to comment.