diff options
| author | gramanas <anastasis.gramm2@gmail.com> | 2018-10-27 12:35:07 +0300 | 
|---|---|---|
| committer | gramanas <anastasis.gramm2@gmail.com> | 2018-10-27 12:39:01 +0300 | 
| commit | 2922690b716540b7e3971ffbdf506148503c7788 (patch) | |
| tree | ccb6a4dbbffadf5f91ee47ca5ef5bd8347c02a1c /src/actionhelper.c | |
| parent | 1b09a70af6096d2f85cadff82f227e4e6850bfda (diff) | |
| download | ck-2922690b716540b7e3971ffbdf506148503c7788.tar.gz ck-2922690b716540b7e3971ffbdf506148503c7788.tar.bz2 ck-2922690b716540b7e3971ffbdf506148503c7788.zip  | |
change own&grp when it should. version 0.8.1!
Diffstat (limited to 'src/actionhelper.c')
| -rw-r--r-- | src/actionhelper.c | 44 | 
1 files changed, 33 insertions, 11 deletions
diff --git a/src/actionhelper.c b/src/actionhelper.c index 0269470..6428ab0 100644 --- a/src/actionhelper.c +++ b/src/actionhelper.c @@ -266,19 +266,25 @@ int restore_make_links(cklist *from, cklist *to) {    if (list_size(from) > 0        && list_size(to) > 0        && list_size(from) == list_size(to)) { -    while (1) { -      HELP("%s %d %d", list_get(to), util_file_exists(list_get(to), NULL), !util_is_file_link(list_get(to))); +    do {        if (util_file_exists(list_get(to), NULL)            || !util_is_file_link(list_get(to))) { -        sERR("File %s already exists. Terminating.", list_get(to)); +        ERR("File %s already exists.", list_get(to)); +        sERR("No links were created.");          return -1;        } +    } while (list_next(to)); +    list_rewind(to); +    while (1) {        if (util_symlink_file(list_get(from), list_get(to))) { -        sERR("Failed: %s -> %s", list_get(from), list_get(to)); +        ERR("FATAL could not link %s -> %s", list_get(from), list_get(to)); +        sERR("Process stopping."); +        return -1; +      } +      hLOG("Linking: %s -> %s", list_get(from), list_get(to)); +      if (util_own_grp_copy(list_get(to), list_get(from))) {          return -1;        } -      LOG("Linking: %s -> %s", list_get(from), list_get(to)); -      HELP("Linking: %s -> %s", list_get(from), list_get(to));        if (!list_next(from)) {          break;        } @@ -348,11 +354,9 @@ void print_HELP_result(int err) {  }  void print_RESTORE_result(int err) { -  if (!err) { -    HELP("restore OK"); -    return; +  if (err == -1) { +    sERR("Restore failed.")    } -  sERR("restore NOT OK");  }  void print_INIT_help() { @@ -445,7 +449,25 @@ void print_HELP_help() {  }  void print_RESTORE_help() { -  ckhelp("Restore help"); +  ckhelp("Restore links.\n"); +  ckhelp("Given a working ck instance (ckdb + ckrc + directories in ckrc with configs)"); +  ckhelp("restore shall recreate the links from the config directories in ckrc"); +  ckhelp("back to their corresponding position when added in ck.\n"); +  ckhelp("It is useful for copying your configs to a new linux installation"); +  ckhelp("or restoring deleted links.\n"); +  ckhelp("It can either restore a specific program or all of them:"); +  ckhelp("  `-p progName`: restores progName."); +  ckhelp("  `all`: restores everything.\n"); +  ckhelp("Note:\nIf ck tracks configs that are owned by root, simply running"); +  ckhelp("`ck restore ...` will fail due to permissions. To remedy this, ck will alter the"); +  ckhelp("owner and group of a link to match the one in the ckrc directories."); +  ckhelp("Thus, running `sudo ck -c /home/myuser/.ck restore ..` will restore"); +  ckhelp("the root user's links as it should and the user links will have"); +  ckhelp("the user as the owner instead of the root.\n"); +  ckhelp("ck checks that the configs exist and that the location for the link"); +  ckhelp("is avaliable before making any links. However, in the even that symlink"); +  ckhelp("fails for some other reason, the process will stop as is. Make sure you"); +  ckhelp("take care of the already created links, if that's the case.");    report_help();  }  | 
