change 'example' to 'config'.
This commit is contained in:
parent
5286ec542a
commit
0bc78f353f
@ -52,10 +52,9 @@ void dropshell::autocomplete(const std::vector<std::string> &args)
|
||||
|
||||
if (cmd=="create-service")
|
||||
{ // create-service <server> <template> <service>
|
||||
std::vector<template_info> templates;
|
||||
get_templates(templates);
|
||||
auto templates = dropshell::gTemplateManager().get_template_list();
|
||||
for (const auto& t : templates)
|
||||
std::cout << t.template_name << std::endl;
|
||||
std::cout << t << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -77,14 +77,14 @@ LocalServiceInfo get_service_info(const std::string &server_name, const std::str
|
||||
}
|
||||
service.template_name = it->second;
|
||||
|
||||
template_info tinfo;
|
||||
if (!get_template_info(service.template_name, tinfo)) {
|
||||
template_info tinfo = gTemplateManager().get_template_info(service.template_name);
|
||||
if (!tinfo.is_set()) {
|
||||
std::cerr << "Error: Template '" << service.template_name << "' not found" << std::endl;
|
||||
return LocalServiceInfo();
|
||||
}
|
||||
|
||||
// find the template path
|
||||
service.local_template_path = tinfo.local_template_path;
|
||||
service.local_template_path = tinfo.local_template_path();
|
||||
|
||||
return service;
|
||||
}
|
||||
@ -170,8 +170,8 @@ bool create_service(const std::string &server_name, const std::string &template_
|
||||
return false;
|
||||
}
|
||||
|
||||
template_info tinfo;
|
||||
if (!get_template_info(template_name, tinfo))
|
||||
template_info tinfo = gTemplateManager().get_template_info(template_name);
|
||||
if (!tinfo.is_set())
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
@ -186,8 +186,8 @@ bool create_service(const std::string &server_name, const std::string &template_
|
||||
// create the service directory
|
||||
fs::create_directory(service_dir);
|
||||
|
||||
// copy the template example files to the service directory
|
||||
recursive_copy(tinfo.local_template_path+"/example", service_dir);
|
||||
// copy the template config files to the service directory
|
||||
recursive_copy(tinfo.local_template_path()/"config", service_dir);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
@ -244,9 +244,9 @@ void get_all_service_env_vars(const std::string &server_name, const std::string
|
||||
std::cerr << " " << localpath::service(server_name, service_name) << std::endl << std::endl;
|
||||
return;
|
||||
}
|
||||
template_info tinfo;
|
||||
if (get_template_info(it->second, tinfo))
|
||||
load_env_file(tinfo.local_template_path + "/_default.env");
|
||||
template_info tinfo = gTemplateManager().get_template_info(it->second);
|
||||
if (tinfo.is_set())
|
||||
load_env_file(tinfo.local_template_path()/"_default.env");
|
||||
else
|
||||
std::cerr << "Error: Template '" << it->second << "' not found" << std::endl;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@
|
||||
// modify the TEMPLATE=example line in the .template_info.env file to TEMPLATE=<template_name>
|
||||
std::string search_string = "TEMPLATE=";
|
||||
std::string replacement_line = "TEMPLATE=" + template_name;
|
||||
std::string service_env_path = new_template_path + "/example/.template_info.env";
|
||||
std::string service_env_path = new_template_path + "/config/.template_info.env";
|
||||
if (!replace_line_in_file(service_env_path, search_string, replacement_line)) {
|
||||
std::cerr << "Error: Failed to replace TEMPLATE= line in the .template_info.env file" << std::endl;
|
||||
return;
|
||||
@ -181,11 +181,12 @@
|
||||
std::string template_name = std::filesystem::path(template_path).filename().string();
|
||||
|
||||
std::vector<std::string> required_files = {
|
||||
"example/service.env",
|
||||
"example/.template_info.env",
|
||||
"config/service.env",
|
||||
"config/.template_info.env",
|
||||
"_default.env",
|
||||
"install.sh",
|
||||
"uninstall.sh"
|
||||
"uninstall.sh",
|
||||
"nuke.sh"
|
||||
};
|
||||
|
||||
for (const auto& file : required_files) {
|
||||
@ -197,8 +198,8 @@
|
||||
// check TEMPLATE= line.
|
||||
std::map<std::string, std::string> all_env_vars;
|
||||
std::vector<std::string> env_files = {
|
||||
"example/service.env",
|
||||
"example/.template_info.env"
|
||||
"config/service.env",
|
||||
"config/.template_info.env"
|
||||
};
|
||||
for (const auto& file : env_files) {
|
||||
{ // load service.env from the service on this machine.
|
||||
|
@ -32,7 +32,7 @@ namespace dropshell {
|
||||
// | |-- <template_name>
|
||||
// | |-- (...script files...)
|
||||
// | |-- _default.env
|
||||
// | |-- example
|
||||
// | |-- config
|
||||
// | |-- service.env
|
||||
// | |-- .template_info.env
|
||||
// | |-- (...other service config files...)
|
||||
@ -68,7 +68,7 @@ namespace dropshell {
|
||||
// |-- service.env
|
||||
// |-- template
|
||||
// |-- (script files)
|
||||
// |-- example
|
||||
// |-- config
|
||||
// |-- service.env
|
||||
// |-- (other config files for specific server&service)
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
#include "readmes.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
void dropshell::create_readme_local_config_dir(const std::string &readme_path)
|
||||
{
|
||||
if (std::filesystem::exists(readme_path))
|
||||
return; // already exists
|
||||
|
||||
std::ofstream readme_file(readme_path);
|
||||
// use heredoc to write the readme
|
||||
readme_file << R"(
|
||||
|
||||
use this directory to store your local config files for your servers and services.
|
||||
dropshell create-server <server_name>
|
||||
dropshell create-template <template_name>
|
||||
dropshell create-service <server_name> <template_name> <service_name>
|
||||
|
||||
config_path
|
||||
|-- servers
|
||||
| |-- server_name
|
||||
| |-- server.env
|
||||
| |-- services
|
||||
| |-- service_name
|
||||
| |-- service.env
|
||||
| |-- (other config files for specific server&service)
|
||||
|-- templates
|
||||
| |-- template_name
|
||||
| |-- (script files)
|
||||
| |-- example
|
||||
| |-- service.env
|
||||
| |-- (other service config files)
|
||||
|
||||
)" << std::endl;
|
||||
readme_file.close();
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#ifndef READMES_HPP
|
||||
#define READMES_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace dropshell {
|
||||
|
||||
void create_readme_local_config_dir(const std::string &readme_path);
|
||||
|
||||
} // namespace dropshell
|
||||
|
||||
#endif
|
@ -17,7 +17,7 @@ SCRIPT_DIR="$(dirname "$0")"
|
||||
# // |-- service.env
|
||||
# // |-- template
|
||||
# // |-- (script files)
|
||||
# // |-- example
|
||||
# // |-- config
|
||||
# // |-- service.env
|
||||
# // |-- (other config files for specific server&service)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Service settings specific to this server
|
||||
# (can also override anything in the _default.env file in the template to make it specific to this server)
|
||||
HOST_PORT=60123
|
||||
LOCAL_DATA_FOLDER="${HOME}/.example"
|
||||
LOCAL_DATA_FOLDER="${HOME}/.example-nginx"
|
||||
CONTAINER_NAME=example-nginx
|
||||
IMAGE_TAG="latest"
|
||||
|
||||
|
@ -13,8 +13,6 @@ if [ ! -d "${LOCAL_DATA_FOLDER}" ]; then
|
||||
echo "Creating local data folder ${LOCAL_DATA_FOLDER}..."
|
||||
mkdir -p "${LOCAL_DATA_FOLDER}"
|
||||
chmod 777 "${LOCAL_DATA_FOLDER}"
|
||||
# Optionally, copy default content if needed
|
||||
# cp -r ./example/* "${LOCAL_DATA_FOLDER}/"
|
||||
fi
|
||||
|
||||
echo "Checking Docker installation..."
|
||||
|
Loading…
x
Reference in New Issue
Block a user