#include <algorithm>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "cpbuffer.h"
#include "dinit-client.h"
#include "load-service.h"
+#include "dinit-util.h"
+#include "mconfig.h"
// dinitctl: utility to control the Dinit daemon, including starting and stopping of services.
-// This utility communicates with the dinit daemon via a unix stream socket (/dev/initctl,
-// or $HOME/.dinitctl).
+// This utility communicates with the dinit daemon via a unix stream socket (as specified in
+// SYSCONTROLSOCKET, or $HOME/.dinitctl).
static constexpr uint16_t min_cp_version = 1;
static constexpr uint16_t max_cp_version = 1;
static int issue_load_service(int socknum, const char *service_name, bool find_only = false);
static int check_load_reply(int socknum, cpbuffer_t &, handle_t *handle_p, service_state_t *state_p);
static int start_stop_service(int socknum, cpbuffer_t &, const char *service_name, command_t command,
- bool do_pin, bool wait_for_service, bool verbose);
+ bool do_pin, bool do_force, bool wait_for_service, bool verbose);
static int unpin_service(int socknum, cpbuffer_t &, const char *service_name, bool verbose);
static int unload_service(int socknum, cpbuffer_t &, const char *service_name);
+static int reload_service(int socknum, cpbuffer_t &, const char *service_name);
static int list_services(int socknum, cpbuffer_t &);
static int shutdown_dinit(int soclknum, cpbuffer_t &);
static int add_remove_dependency(int socknum, cpbuffer_t &rbuffer, bool add, const char *service_from,
const char *service_to, dependency_type dep_type);
-static int enable_service(int socknum, cpbuffer_t &rbuffer, const char *from, const char *to);
+static int enable_disable_service(int socknum, cpbuffer_t &rbuffer, const char *from, const char *to,
+ bool enable);
static const char * describeState(bool stopped)
{
START_SERVICE,
WAKE_SERVICE,
STOP_SERVICE,
+ RESTART_SERVICE,
RELEASE_SERVICE,
UNPIN_SERVICE,
UNLOAD_SERVICE,
+ RELOAD_SERVICE,
LIST_SERVICES,
SHUTDOWN,
ADD_DEPENDENCY,
const char * control_socket_path = nullptr;
bool verbose = true;
- bool sys_dinit = false; // communicate with system daemon
+ bool user_dinit = (getuid() != 0); // communicate with user daemon
bool wait_for_service = true;
bool do_pin = false;
+ bool do_force = false;
command_t command = command_t::NONE;
verbose = false;
}
else if (strcmp(argv[i], "--system") == 0 || strcmp(argv[i], "-s") == 0) {
- sys_dinit = true;
+ user_dinit = false;
+ }
+ else if (strcmp(argv[i], "--user") == 0 || strcmp(argv[i], "-u") == 0) {
+ user_dinit = true;
}
else if (strcmp(argv[i], "--pin") == 0) {
do_pin = true;
}
+ else if (strcmp(argv[i], "--socket-path") == 0 || strcmp(argv[i], "-p") == 0) {
+ ++i;
+ if (i == argc) {
+ cerr << "dinitctl: --socket-path/-p should be followed by socket path" << std::endl;
+ return 1;
+ }
+ control_socket_str = argv[i];
+ }
else if ((command == command_t::ENABLE_SERVICE || command == command_t::DISABLE_SERVICE)
&& strcmp(argv[i], "--from") == 0) {
++i;
}
service_name = argv[i];
}
+ else if ((command == command_t::STOP_SERVICE || command == command_t::RESTART_SERVICE)
+ && (strcmp(argv[i], "--force") == 0 || strcmp(argv[i], "-f") == 0)) {
+ do_force = true;
+ }
else {
- cerr << "dinitctl: unrecognized option: " << argv[i] << " (use --help for help)\n";
+ cerr << "dinitctl: unrecognized/invalid option: " << argv[i] << " (use --help for help)\n";
return 1;
}
}
else if (strcmp(argv[i], "stop") == 0) {
command = command_t::STOP_SERVICE;
}
+ else if (strcmp(argv[i], "restart") == 0) {
+ command = command_t::RESTART_SERVICE;
+ }
else if (strcmp(argv[i], "release") == 0) {
command = command_t::RELEASE_SERVICE;
}
else if (strcmp(argv[i], "unload") == 0) {
command = command_t::UNLOAD_SERVICE;
}
+ else if (strcmp(argv[i], "reload") == 0) {
+ command = command_t::RELOAD_SERVICE;
+ }
else if (strcmp(argv[i], "list") == 0) {
command = command_t::LIST_SERVICES;
}
else if (strcmp(argv[i], "enable") == 0) {
command = command_t::ENABLE_SERVICE;
}
+ else if (strcmp(argv[i], "disable") == 0) {
+ command = command_t::DISABLE_SERVICE;
+ }
else {
cerr << "dinitctl: unrecognized command: " << argv[i] << " (use --help for help)\n";
return 1;
bool no_service_cmd = (command == command_t::LIST_SERVICES || command == command_t::SHUTDOWN);
- if (service_name != nullptr && no_service_cmd) {
+ if (command == command_t::ENABLE_SERVICE || command == command_t::DISABLE_SERVICE) {
+ show_help |= (to_service_name == nullptr);
+ }
+ else if ((service_name == nullptr && ! no_service_cmd) || command == command_t::NONE) {
show_help = true;
}
-
- if ((service_name == nullptr && ! no_service_cmd) || command == command_t::NONE) {
+
+ if (service_name != nullptr && no_service_cmd) {
show_help = true;
}
"Usage:\n"
" dinitctl [options] start [options] <service-name>\n"
" dinitctl [options] stop [options] <service-name>\n"
+ " dinitctl [options] restart [options] <service-name>\n"
" dinitctl [options] wake [options] <service-name>\n"
" dinitctl [options] release [options] <service-name>\n"
" dinitctl [options] unpin <service-name>\n"
- " dinitctl unload <service-name>\n"
- " dinitctl list\n"
- " dinitctl shutdown\n"
- " dinitctl add-dep <type> <from-service> <to-service>\n"
- " dinitctl rm-dep <type> <from-service> <to-service>\n"
+ " dinitctl [options] unload <service-name>\n"
+ " dinitctl [options] reload <service-name>\n"
+ " dinitctl [options] list\n"
+ " dinitctl [options] shutdown\n"
+ " dinitctl [options] add-dep <type> <from-service> <to-service>\n"
+ " dinitctl [options] rm-dep <type> <from-service> <to-service>\n"
+ " dinitctl [options] enable [--from <from-service>] <to-service>\n"
+ " dinitctl [options] disable [--from <from-service>] <to-service>\n"
"\n"
"Note: An activated service continues running when its dependents stop.\n"
"\n"
"General options:\n"
- " -s, --system : control system daemon instead of user daemon\n"
+ " --help : show this help\n"
+ " -s, --system : control system daemon (default if run as root)\n"
+ " -u, --user : control user daemon\n"
" --quiet : suppress output (except errors)\n"
+ " --socket-path <path>, -p <path>\n"
+ " : specify socket for communication with daemon\n"
"\n"
"Command options:\n"
- " --help : show this help\n"
" --no-wait : don't wait for service startup/shutdown to complete\n"
- " --pin : pin the service in the requested state\n";
+ " --pin : pin the service in the requested state\n"
+ " --force : force stop even if dependents will be affected\n";
return 1;
}
signal(SIGPIPE, SIG_IGN);
- control_socket_path = "/dev/dinitctl";
-
// Locate control socket
- if (! sys_dinit) {
- char * userhome = getenv("HOME");
- if (userhome == nullptr) {
- struct passwd * pwuid_p = getpwuid(getuid());
- if (pwuid_p != nullptr) {
- userhome = pwuid_p->pw_dir;
+ if (! control_socket_str.empty()) {
+ control_socket_path = control_socket_str.c_str();
+ }
+ else {
+ control_socket_path = SYSCONTROLSOCKET; // default to system
+ if (user_dinit) {
+ char * userhome = getenv("HOME");
+ if (userhome == nullptr) {
+ struct passwd * pwuid_p = getpwuid(getuid());
+ if (pwuid_p != nullptr) {
+ userhome = pwuid_p->pw_dir;
+ }
+ }
+
+ if (userhome != nullptr) {
+ control_socket_str = userhome;
+ control_socket_str += "/.dinitctl";
+ control_socket_path = control_socket_str.c_str();
+ }
+ else {
+ cerr << "dinitctl: Cannot locate user home directory (set HOME, check /etc/passwd file, or "
+ "specify socket path via -p)" << endl;
+ return 1;
}
- }
-
- if (userhome != nullptr) {
- control_socket_str = userhome;
- control_socket_str += "/.dinitctl";
- control_socket_path = control_socket_str.c_str();
- }
- else {
- cerr << "Cannot locate user home directory (set HOME or check /etc/passwd file)" << endl;
- return 1;
}
}
int socknum = socket(AF_UNIX, SOCK_STREAM, 0);
if (socknum == -1) {
- perror("dinitctl: socket");
+ perror("dinitctl: error opening socket");
return 1;
}
int connr = connect(socknum, (struct sockaddr *) name, sockaddr_size);
if (connr == -1) {
- perror("dinitctl: connect");
+ perror((std::string("dinitctl: connecting to socket ") + control_socket_path).c_str());
return 1;
}
else if (command == command_t::UNLOAD_SERVICE) {
return unload_service(socknum, rbuffer, service_name);
}
+ else if (command == command_t::RELOAD_SERVICE) {
+ return reload_service(socknum, rbuffer, service_name);
+ }
else if (command == command_t::LIST_SERVICES) {
return list_services(socknum, rbuffer);
}
return add_remove_dependency(socknum, rbuffer, command == command_t::ADD_DEPENDENCY,
service_name, to_service_name, dep_type);
}
- else if (command == command_t::ENABLE_SERVICE) {
+ else if (command == command_t::ENABLE_SERVICE || command == command_t::DISABLE_SERVICE) {
// If only one service specified, assume that we enable for 'boot' service:
if (service_name == nullptr) {
service_name = "boot";
}
- return enable_service(socknum, rbuffer, service_name, to_service_name);
+ return enable_disable_service(socknum, rbuffer, service_name, to_service_name,
+ command == command_t::ENABLE_SERVICE);
}
else {
- return start_stop_service(socknum, rbuffer, service_name, command, do_pin,
+ return start_stop_service(socknum, rbuffer, service_name, command, do_pin, do_force,
wait_for_service, verbose);
}
}
static std::string read_string(int socknum, cpbuffer_t &rbuffer, uint32_t length)
{
int rb_len = rbuffer.get_length();
- if (rb_len >= length) {
+ if (uint32_t(rb_len) >= length) {
std::string r = rbuffer.extract_string(0, length);
rbuffer.consume(length);
return r;
// name - the name of the service to load
// handle - where to store the handle of the loaded service
// state - where to store the state of the loaded service (may be null).
-static bool load_service(int socknum, cpbuffer_t &rbuffer, const char *name, handle_t *handle, service_state_t *state)
+static bool load_service(int socknum, cpbuffer_t &rbuffer, const char *name, handle_t *handle,
+ service_state_t *state)
{
// Load 'to' service:
if (issue_load_service(socknum, name)) {
return true;
}
+// Get the service name for a given handle, by querying the daemon.
+static std::string get_service_name(int socknum, cpbuffer_t &rbuffer, handle_t handle)
+{
+ auto m = membuf()
+ .append((char) DINIT_CP_QUERYSERVICENAME)
+ .append((char) 0)
+ .append(handle);
+ write_all_x(socknum, m);
+
+ wait_for_reply(rbuffer, socknum);
+
+ if (rbuffer[0] != DINIT_RP_SERVICENAME) {
+ throw cp_read_exception{0};
+ }
+
+ // 1 byte reserved
+ // uint16_t size
+ fill_buffer_to(rbuffer, socknum, 2 + sizeof(uint16_t));
+ uint16_t namesize;
+ rbuffer.extract(&namesize, 2, sizeof(uint16_t));
+ rbuffer.consume(2 + sizeof(uint16_t));
+
+ std::string name;
+
+ do {
+ if (rbuffer.get_length() == 0) {
+ rbuffer.fill(socknum);
+ }
+
+ size_t to_extract = std::min(size_t(rbuffer.get_length()), namesize - name.length());
+ size_t contiguous_len = rbuffer.get_contiguous_length(rbuffer.get_ptr(0));
+ if (contiguous_len <= to_extract) {
+ name.append(rbuffer.get_ptr(0), contiguous_len);
+ rbuffer.consume(contiguous_len);
+ name.append(rbuffer.get_ptr(0), to_extract - contiguous_len);
+ rbuffer.consume(to_extract - contiguous_len);
+ }
+ else {
+ name.append(rbuffer.get_ptr(0), to_extract);
+ rbuffer.consume(to_extract);
+ break;
+ }
+
+ } while (name.length() < namesize);
+
+ return name;
+}
+
// Start/stop a service
static int start_stop_service(int socknum, cpbuffer_t &rbuffer, const char *service_name,
- command_t command, bool do_pin, bool wait_for_service, bool verbose)
+ command_t command, bool do_pin, bool do_force, bool wait_for_service, bool verbose)
{
using namespace std;
int pcommand = 0;
switch (command) {
case command_t::STOP_SERVICE:
+ case command_t::RESTART_SERVICE: // stop, and then start
pcommand = DINIT_CP_STOPSERVICE;
break;
case command_t::RELEASE_SERVICE:
// We'll do this regardless of the current service state / target state, since issuing
// start/stop also sets or clears the "explicitly started" flag on the service.
{
- char buf[2 + sizeof(handle)];
- buf[0] = pcommand;
- buf[1] = do_pin ? 1 : 0;
- memcpy(buf + 2, &handle, sizeof(handle));
- write_all_x(socknum, buf, 2 + sizeof(handle));
-
+ char flags = (do_pin ? 1 : 0) | ((pcommand == DINIT_CP_STOPSERVICE && !do_force) ? 2 : 0);
+ if (command == command_t::RESTART_SERVICE) {
+ flags |= 4;
+ }
+
+ auto m = membuf()
+ .append((char) pcommand)
+ .append(flags)
+ .append(handle);
+ write_all_x(socknum, m);
+
wait_for_reply(rbuffer, socknum);
- if (rbuffer[0] == DINIT_RP_ALREADYSS) {
+ auto reply_pkt_h = rbuffer[0];
+ rbuffer.consume(1); // consume header
+ if (reply_pkt_h == DINIT_RP_ALREADYSS) {
bool already = (state == wanted_state);
if (verbose) {
cout << "Service " << (already ? "(already) " : "")
}
return 0; // success!
}
- if (rbuffer[0] != DINIT_RP_ACK) {
- cerr << "dinitctl: Protocol error." << endl;
+ if (reply_pkt_h == DINIT_RP_DEPENDENTS && pcommand == DINIT_CP_STOPSERVICE) {
+ cerr << "dinitctl: cannot stop service due to the following dependents:\n";
+ if (command != command_t::RESTART_SERVICE) {
+ cerr << "(Only direct dependents are listed. Exercise caution before using '--force' !!)\n";
+ }
+ // size_t number, N * handle_t handles
+ size_t number;
+ rbuffer.fill_to(socknum, sizeof(number));
+ rbuffer.extract(&number, 0, sizeof(number));
+ rbuffer.consume(sizeof(number));
+ std::vector<handle_t> handles;
+ handles.reserve(number);
+ for (size_t i = 0; i < number; i++) {
+ handle_t handle;
+ rbuffer.fill_to(socknum, sizeof(handle_t));
+ rbuffer.extract(&handle, 0, sizeof(handle));
+ handles.push_back(handle);
+ rbuffer.consume(sizeof(handle));
+ }
+ // Print the directly affected dependents:
+ cerr << " ";
+ for (handle_t handle : handles) {
+ cerr << " " << get_service_name(socknum, rbuffer, handle);
+ }
+ cerr << "\n";
+ return 1;
+ }
+ if (reply_pkt_h == DINIT_RP_NAK && command == command_t::RESTART_SERVICE) {
+ cerr << "dinitctl: cannot restart service; service not started.\n";
+ return 1;
+ }
+ if (reply_pkt_h == DINIT_RP_NAK && command == command_t::START_SERVICE) {
+ cerr << "dinitctl: cannot start service (during shut down).\n";
+ return 1;
+ }
+ if (reply_pkt_h == DINIT_RP_NAK && command == command_t::WAKE_SERVICE) {
+ cerr << "dinitctl: service has no active dependents (or system is shutting down), cannot wake.\n";
+ return 1;
+ }
+ if (reply_pkt_h != DINIT_RP_ACK && reply_pkt_h != DINIT_RP_ALREADYSS) {
+ cerr << "dinitctl: protocol error." << endl;
return 1;
}
- rbuffer.consume(1);
}
if (! wait_for_service) {
// Issue UNPIN command.
{
- char buf[1 + sizeof(handle)];
- buf[0] = DINIT_CP_UNPINSERVICE;
- memcpy(buf + 1, &handle, sizeof(handle));
- write_all_x(socknum, buf, 2 + sizeof(handle));
+ auto m = membuf()
+ .append<char>(DINIT_CP_UNPINSERVICE)
+ .append(handle);
+ write_all_x(socknum, m);
wait_for_reply(rbuffer, socknum);
if (rbuffer[0] != DINIT_RP_ACK) {
// Issue UNLOAD command.
{
- char buf[1 + sizeof(handle)];
- buf[0] = DINIT_CP_UNLOADSERVICE;
- memcpy(buf + 1, &handle, sizeof(handle));
- write_all_x(socknum, buf, 2 + sizeof(handle));
+ auto m = membuf()
+ .append<char>(DINIT_CP_UNLOADSERVICE)
+ .append(handle);
+ write_all_x(socknum, m);
wait_for_reply(rbuffer, socknum);
if (rbuffer[0] == DINIT_RP_NAK) {
return 0;
}
+static int reload_service(int socknum, cpbuffer_t &rbuffer, const char *service_name)
+{
+ using namespace std;
+
+ if (issue_load_service(socknum, service_name, true) == 1) {
+ return 1;
+ }
+
+ wait_for_reply(rbuffer, socknum);
+
+ handle_t handle;
+
+ if (rbuffer[0] == DINIT_RP_NOSERVICE) {
+ cerr << "dinitctl: service not loaded." << endl;
+ return 1;
+ }
+
+ if (check_load_reply(socknum, rbuffer, &handle, nullptr) != 0) {
+ return 1;
+ }
+
+ // Issue RELOAD command.
+ {
+ auto m = membuf()
+ .append<char>(DINIT_CP_RELOADSERVICE)
+ .append(handle);
+ write_all_x(socknum, m);
+
+ wait_for_reply(rbuffer, socknum);
+ if (rbuffer[0] == DINIT_RP_NAK) {
+ cerr << "dinitctl: Could not reload service; service in wrong state, incompatible change, "
+ "or bad service description." << endl;
+ return 1;
+ }
+ if (rbuffer[0] != DINIT_RP_ACK) {
+ cerr << "dinitctl: Protocol error." << endl;
+ return 1;
+ }
+ rbuffer.consume(1);
+ }
+
+ cout << "Service reloaded." << endl;
+ return 0;
+}
+
static int list_services(int socknum, cpbuffer_t &rbuffer)
{
using namespace std;
cout << " (exit status: " << WEXITSTATUS(exit_status) << ")";
}
else if (WIFSIGNALED(exit_status)) {
- cout << " (signal: " << WSTOPSIG(exit_status) << ")";
+ cout << " (signal: " << WTERMSIG(exit_status) << ")";
}
}
{
using namespace std;
-
handle_t from_handle;
handle_t to_handle;
return 1;
}
- constexpr int pktsize = 2 + sizeof(handle_t) * 2;
- char cmdbuf[pktsize] = { add ? (char)DINIT_CP_ADD_DEP : (char)DINIT_CP_REM_DEP, (char)dep_type};
- memcpy(cmdbuf + 2, &from_handle, sizeof(from_handle));
- memcpy(cmdbuf + 2 + sizeof(from_handle), &to_handle, sizeof(to_handle));
- write_all_x(socknum, cmdbuf, pktsize);
+ auto m = membuf()
+ .append<char>(add ? (char)DINIT_CP_ADD_DEP : (char)DINIT_CP_REM_DEP)
+ .append(dep_type)
+ .append(from_handle)
+ .append(to_handle);
+ write_all_x(socknum, m);
wait_for_reply(rbuffer, socknum);
// TODO support no-wait option.
using namespace std;
- // Build buffer;
- constexpr int bufsize = 2;
- char buf[bufsize];
-
- buf[0] = DINIT_CP_SHUTDOWN;
- buf[1] = static_cast<char>(shutdown_type_t::HALT);
-
- write_all_x(socknum, buf, bufsize);
+ auto m = membuf()
+ .append<char>(DINIT_CP_SHUTDOWN)
+ .append(static_cast<char>(shutdown_type_t::HALT));
+ write_all_x(socknum, m);
wait_for_reply(rbuffer, socknum);
return 1;
}
- // Now wait for rollback complete:
+ // Now wait for rollback complete, by waiting for the connection to close:
try {
while (true) {
wait_for_info(rbuffer, socknum);
- if (rbuffer[0] == DINIT_ROLLBACK_COMPLETED) {
- break;
- }
+ rbuffer.consume(rbuffer[1]);
}
}
catch (cp_read_exception &exc) {
- // Dinit can terminate before replying: let's assume that happened.
- // TODO: better check, possibly ensure that dinit actually sends rollback complete before
- // termination.
+ // Assume that the connection closed.
}
return 0;
}
-// Join two paths; the 2nd must be relative
-static std::string join_paths(std::string p1, std::string p2)
-{
- std::string r = p1;
- if (*(r.rbegin()) != '/') {
- r += '/';
- }
- return r + p2;
-}
-
// exception for cancelling a service operation
class service_op_cancel { };
-static int enable_service(int socknum, cpbuffer_t &rbuffer, const char *from, const char *to)
+static int enable_disable_service(int socknum, cpbuffer_t &rbuffer, const char *from, const char *to,
+ bool enable)
{
using namespace std;
string service_file_path;
for (std::string path : paths) {
- string test_path = join_paths(dinit_cwd + '/' + path, from);
+ string test_path = combine_paths(combine_paths(dinit_cwd, path.c_str()), from);
service_file.open(test_path.c_str(), ios::in);
if (service_file) {
return 1;
}
+ // The waits-for.d path is relative to the service file path, combine:
+ string waits_for_d_full = combine_paths(parent_path(service_file_path), waits_for_d.c_str());
+
// check if dependency already exists
- string dep_link_path = join_paths(waits_for_d, to);
+ string dep_link_path = combine_paths(waits_for_d_full, to);
struct stat stat_buf;
if (lstat(dep_link_path.c_str(), &stat_buf) == -1) {
if (errno != ENOENT) {
}
else {
// dependency already exists
- cerr << "dinitctl: service already enabled." << endl;
- return 1;
+ if (enable) {
+ cerr << "dinitctl: service already enabled." << endl;
+ return 1;
+ }
}
// warn if 'from' service is not started
- if (from_state != service_state_t::STARTED) {
+ if (enable && from_state != service_state_t::STARTED) {
cerr << "dinitctl: warning: enabling dependency for non-started service" << endl;
}
- // add dependency
+ // add/remove dependency
constexpr int enable_pktsize = 2 + sizeof(handle_t) * 2;
- char cmdbuf[enable_pktsize] = { char(DINIT_CP_ENABLESERVICE), char(dependency_type::WAITS_FOR)};
+ char cmdbuf[enable_pktsize] = { char(enable ? DINIT_CP_ENABLESERVICE : DINIT_CP_REM_DEP),
+ char(dependency_type::WAITS_FOR)};
memcpy(cmdbuf + 2, &from_handle, sizeof(from_handle));
memcpy(cmdbuf + 2 + sizeof(from_handle), &to_handle, sizeof(to_handle));
write_all_x(socknum, cmdbuf, enable_pktsize);
wait_for_reply(rbuffer, socknum);
// check reply
- if (rbuffer[0] == DINIT_RP_NAK) {
+ if (enable && rbuffer[0] == DINIT_RP_NAK) {
cerr << "dinitctl: Could not enable service: possible circular dependency" << endl;
return 1;
}
}
// create link
- if (symlink(dep_link_path.c_str(), (string("../") + to).c_str()) == -1) {
- cerr << "dinitctl: Could not create symlink at " << dep_link_path << ": " << strerror(errno) << "\n"
- "dinitctl: Note: service was activated, but will not be enabled on restart." << endl;
- return 1;
+ if (enable) {
+ if (symlink((string("../") + to).c_str(), dep_link_path.c_str()) == -1) {
+ cerr << "dinitctl: Could not create symlink at " << dep_link_path << ": " << strerror(errno)
+ << "\n" "dinitctl: Note: service was activated, but will not be enabled on restart."
+ << endl;
+ return 1;
+ }
+ }
+ else {
+ if (unlink(dep_link_path.c_str()) == -1) {
+ cerr << "dinitctl: Could not unlink dependency entry " << dep_link_path << ": "
+ << strerror(errno) << "\n"
+ "dinitctl: Note: service was disabled, but will be re-enabled on restart." << endl;
+ return 1;
+ }
}
return 0;