403Webshell
Server IP : 34.87.99.72  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n
System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64
User : bitnami ( 1000)
PHP Version : 7.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/bitnami/nami/node_modules/provisioner/lib/recipes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/bitnami/nami/node_modules/provisioner/lib/recipes/configure_host.js
/// <reference path="../../typings-recipe.d.ts" />
/*
 * Run configureHost for specific tiers and modules
 */
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
recipes.register({
    id: "create-configure-app-domain-script",
    on: { afterInitialize: {} },
    conditions: {
        shouldInvoke: () => provisioner.tierDefinition.filterModulesByAssetType("bash").some((m) => {
            return m.exportsFunction("configureHost");
        }),
    },
    recipeHandler: function (input) {
        const scriptPath = $file.join(platform.pathInfo.namiAppPath, "configure_app_domain");
        const scriptContents = `#!/bin/bash

if [[ "$(id -u)" -ne "0" ]]; then
    echo "This script must be run as a superuser"
    exit 1
fi

# Help menu
display_help() {
    echo "Usage: $0 [arguments...]"
    echo
    echo "Options:"
    echo "  -h, --help                         show help menu"
    echo "  --domain arg                       configure application domain and exit"
    echo "  --enable-automatic-configuration   enable automatic IP configuration"
    echo "  --disable-automatic-configuration  disable automatic IP configuration"
}

# Default options
domain=""
disable_automatic_updates=true

if [[ "$#" -eq 0 ]]; then
    echo "No arguments were specified"
    display_help
    exit 1
fi

# Parse CLI arguments
while [[ "$#" -gt 0 ]]; do
    case "$1" in
        --domain)
            shift
            domain="\${1:?missing domain value}"
            ;;
        --disable-automatic-configuration)
            disable_automatic_updates=true
            ;;
        --enable-automatic-configuration)
            disable_automatic_updates=false
            ;;
        -h|--help)
            display_help
            exit
            ;;
        *)
            echo "Unknown parameter $1"
            display_help
            exit 1
    esac
    shift
done

# Paths to modifier files
app_domain_file="${$file.join(platform.pathInfo.namiAppPath, ".app_domain")}"
disable_file="${$file.join(platform.pathInfo.namiAppPath, ".app_domain_disabled")}"

# Updates the domain for all installed apps
update_domains() {
    ${$file.join(platform.pathInfo.namiAppPath, "nami/bin/provisioner")} --only-recipes configure-host callRecipes afterStart
}

if "$disable_automatic_updates"; then
    # Configuring a domain will always disable automatic domain configuration when the IP address changes
    if [[ -n "$domain" ]]; then
        echo "Configuring domain to \${domain}"
        echo "$domain" > "$app_domain_file"
        rm -f "$disable_file"
        update_domains
    fi

    echo "Disabling automatic domain update for IP address changes"
    touch "$disable_file"
else
    echo "Enabling automatic domain update for IP address changes"
    rm -f "$app_domain_file" "$disable_file"
    update_domains
fi
`;
        $file.write(scriptPath, scriptContents);
        $file.chmod(scriptPath, "0755");
    }
});
recipes.register({
    id: "configure-host",
    on: { afterStart: {} },
    conditions: {
        shouldInvoke: () => !$file.exists($file.join(platform.pathInfo.namiAppPath, ".app_domain_disabled")),
        ifChanged: (input) => {
            const appDomainFile = $file.join(platform.pathInfo.namiAppPath, ".app_domain");
            // Externally provisioned machines store the machine IP type in a file
            const machineIpTypeFile = $file.join(platform.pathInfo.namiAppPath, "var/data/machine_ip_type");
            if ($file.exists(appDomainFile)) {
                return $file.read(appDomainFile).trim();
            }
            else if ($file.contains(machineIpTypeFile, "private")) {
                return provisioner.cloud.getMetaData("private-ipv4");
            }
            else {
                return provisioner.cloud.getMetaData("public-ipv4");
            }
        }
    },
    recipeHandler: function (input) {
        return __awaiter(this, void 0, void 0, function* () {
            let ip = input.newValue;
            for (const m of provisioner.tierDefinition.modules) {
                if (m.exportsFunction("configureHost")) {
                    m.runExport("configureHost", [ip]);
                }
            }
        });
    }
});

Youez - 2016 - github.com/yon3zu
LinuXploit