summaryrefslogtreecommitdiffstats
path: root/extras/hook-scripts
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2015-12-11 00:37:13 +0100
committerNiels de Vos <ndevos@redhat.com>2015-12-17 04:11:36 -0800
commitce3ff7e328483dffdae6ae2914924bc2380db67e (patch)
tree3daa564a947b1c7a1eebb5249717abd3dcf9c441 /extras/hook-scripts
parent692ccdbd4d11311a1967d62227666d2c473ea233 (diff)
hook-scripts: fix S30Samba scripts on systemd systems
/etc/init.d/smb does not exist on systemd systems. Using "service smb <COMMAND>" is the portable way. It calls init scripts on sysv systems, and redirects to systemctl on systemd systems. Change-Id: I7146c9998a51d8b170d3321f3477e92704ae7615 BUG: 1290604 Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-on: http://review.gluster.org/12945 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anoop C S <anoopcs@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'extras/hook-scripts')
-rwxr-xr-xextras/hook-scripts/set/post/S30samba-set.sh2
-rwxr-xr-xextras/hook-scripts/start/post/S30samba-start.sh2
-rwxr-xr-xextras/hook-scripts/stop/pre/S30samba-stop.sh2
3 files changed, 3 insertions, 3 deletions
diff --git a/extras/hook-scripts/set/post/S30samba-set.sh b/extras/hook-scripts/set/post/S30samba-set.sh
index e359059992b..97d067fc33f 100755
--- a/extras/hook-scripts/set/post/S30samba-set.sh
+++ b/extras/hook-scripts/set/post/S30samba-set.sh
@@ -99,7 +99,7 @@ function sighup_samba () {
then
kill -HUP "$pid";
else
- /etc/init.d/smb condrestart
+ service smb condrestart
fi
}
diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh
index 43dc8e108da..752eca650d3 100755
--- a/extras/hook-scripts/start/post/S30samba-start.sh
+++ b/extras/hook-scripts/start/post/S30samba-start.sh
@@ -82,7 +82,7 @@ function sighup_samba () {
then
kill -HUP "$pid";
else
- /etc/init.d/smb condrestart
+ service smb condrestart
fi
}
diff --git a/extras/hook-scripts/stop/pre/S30samba-stop.sh b/extras/hook-scripts/stop/pre/S30samba-stop.sh
index 8950eea436e..62cf7d1e0d2 100755
--- a/extras/hook-scripts/stop/pre/S30samba-stop.sh
+++ b/extras/hook-scripts/stop/pre/S30samba-stop.sh
@@ -61,7 +61,7 @@ function sighup_samba () {
then
kill -HUP $pid;
else
- /etc/init.d/smb condrestart
+ service smb condrestart
fi
}
dir_name = dirname (tmp_str); /* check for the errno, if its ENOENT create directory and call * rename later */ tmp_path = gf_strdup (dir_name); if (!tmp_path) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } tmp_loc.path = tmp_path; /* TODO: create the directory with proper permissions */ STACK_WIND_COOKIE (frame, trash_rename_mkdir_cbk, tmp_path, this->children->xlator, this->children->xlator->fops->mkdir, &tmp_loc, 0755, NULL); GF_FREE (tmp_str); return 0; } if ((op_ret == -1) && (op_errno == ENOTDIR)) { gf_log (this->name, GF_LOG_DEBUG, "target(%s) exists, cannot keep the dest entry(%s): " "renaming", local->newpath, local->origpath); } else if ((op_ret == -1) && (op_errno == EISDIR)) { gf_log (this->name, GF_LOG_DEBUG, "target(%s) exists as a directory, cannot keep the " "copy (%s), renaming", local->newpath, local->origpath); } STACK_WIND (frame, trash_common_rename_cbk, this->children->xlator, this->children->xlator->fops->rename, &local->loc, &local->newloc); return 0; } int32_t trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *stbuf, struct iatt *preparent, struct iatt *postparent) { trash_local_t *local = NULL; char *tmp_str = NULL; char *tmp_path = NULL; char *tmp_dirname = NULL; char *dir_name = NULL; int32_t count = 0; loc_t tmp_loc = {0,}; local = frame->local; tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); goto out; } if ((op_ret == -1) && (op_errno == ENOENT)) { tmp_dirname = strchr (tmp_str, '/'); while (tmp_dirname) { count = tmp_dirname - tmp_str; if (count == 0) count = 1; tmp_dirname = strchr (tmp_str + count + 1, '/'); tmp_path = memdup (local->newpath, count); if (!tmp_path) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } tmp_loc.path = tmp_path; /* TODO: create the directory with proper permissions */ STACK_WIND_COOKIE (frame, trash_rename_mkdir_cbk, tmp_path, this->children->xlator, this->children->xlator->fops->mkdir, &tmp_loc, 0755, NULL); } goto out; } dir_name = dirname (tmp_str); if (strcmp ((char*)cookie, dir_name) == 0) { tmp_loc.path = local->newpath; STACK_WIND (frame, trash_rename_rename_cbk, this->children->xlator, this->children->xlator->fops->rename, &local->newloc, &tmp_loc); } out: GF_FREE (cookie); /* strdup (dir_name) was sent here :) */ if (tmp_str) GF_FREE (tmp_str); return 0; } int32_t trash_rename_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf, dict_t *xattr, struct iatt *postparent) { trash_private_t *priv = NULL; trash_local_t *local = NULL; loc_t tmp_loc = {0,}; local = frame->local; priv = this->private; if (op_ret == -1) { STACK_WIND (frame, trash_common_rename_cbk, this->children->xlator, this->children->xlator->fops->rename, &local->loc, &local->newloc); return 0; } if ((buf->ia_size == 0) || (buf->ia_size > priv->max_trash_file_size)) { /* if the file is too big or zero, just unlink it */ if (buf->ia_size > priv->max_trash_file_size) { gf_log (this->name, GF_LOG_DEBUG, "%s: file size too big (%"PRId64") to " "move into trash directory", local->newloc.path, buf->ia_size); } STACK_WIND (frame, trash_common_rename_cbk, this->children->xlator, this->children->xlator->fops->rename, &local->loc, &local->newloc); return 0; } tmp_loc.path = local->newpath; STACK_WIND (frame, trash_rename_rename_cbk, this->children->xlator, this->children->xlator->fops->rename, &local->newloc, &tmp_loc); return 0; } int32_t trash_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc) { trash_elim_pattern_t *trav = NULL; trash_private_t *priv = NULL; trash_local_t *local = NULL; struct tm *tm = NULL; char timestr[256] = {0,}; time_t utime = 0; int32_t match = 0; priv = this->private; if (priv->eliminate) { trav = priv->eliminate; while (trav) { if (fnmatch(trav->pattern, newloc->name, 0) == 0) { match++; break; } trav = trav->next; } } if ((strncmp (oldloc->path, priv->trash_dir, strlen (priv->trash_dir)) == 0) || match) { /* Trying to rename from the trash dir, do the actual rename */ STACK_WIND (frame, trash_common_rename_cbk, this->children->xlator, this->children->xlator->fops->rename, oldloc, newloc); return 0; } local = GF_CALLOC (1, sizeof (trash_local_t), gf_trash_mt_trash_local_t); if (!local) { gf_log (this->name, GF_LOG_ERROR, "out of memory"); TRASH_STACK_UNWIND (rename, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, NULL); return 0; } frame->local = local; loc_copy (&local->loc, oldloc); loc_copy (&local->newloc, newloc); strcpy (local->origpath, newloc->path); strcpy (local->newpath, priv->trash_dir); strcat (local->newpath, newloc->path); { /* append timestamp to file name */ /* TODO: can we make it optional? */ utime = time (NULL); tm = localtime (&utime); strftime (timestr, 256, ".%Y-%m-%d-%H%M%S", tm); strcat (local->newpath, timestr); } /* Send a lookup call on newloc, to ensure we are not overwriting */ STACK_WIND (frame, trash_rename_lookup_cbk, this->children->xlator, this->children->xlator->fops->lookup, newloc, 0); return 0; } int32_t trash_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) { trash_elim_pattern_t *trav = NULL; trash_private_t *priv = NULL; trash_local_t *local = NULL; struct tm *tm = NULL; char timestr[256] = {0,}; time_t utime = 0; int32_t match = 0; priv = this->private; if (priv->eliminate) { trav = priv->eliminate; while (trav) { if (fnmatch(trav->pattern, loc->name, 0) == 0) { match++; break; } trav = trav->next; } } if ((strncmp (loc->path, priv->trash_dir, strlen (priv->trash_dir)) == 0) || (match)) { if (match) { gf_log (this->name, GF_LOG_DEBUG, "%s: file matches eliminate pattern, " "not moved to trash", loc->name); } else { /* unlink from the trash-dir, not keeping any copy */ ; } STACK_WIND (frame, trash_common_unwind_cbk, this->children->xlator, this->children->xlator->fops->unlink, loc); return 0; } local = GF_CALLOC (1, sizeof (trash_local_t), gf_trash_mt_trash_local_t); if (!local) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); TRASH_STACK_UNWIND (unlink, frame, -1, ENOMEM, NULL, NULL); return 0; } frame->local = local; loc_copy (&local->loc, loc); strcpy (local->origpath, loc->path); strcpy (local->newpath, priv->trash_dir); strcat (local->newpath, loc->path); { /* append timestamp to file name */ /* TODO: can we make it optional? */ utime = time (NULL); tm = localtime (&utime); strftime (timestr, 256, ".%Y-%m-%d-%H%M%S", tm); strcat (local->newpath, timestr); } LOCK_INIT (&frame->lock); STACK_WIND (frame, trash_unlink_stat_cbk, this->children->xlator, this->children->xlator->fops->stat, loc); return 0; } int32_t trash_truncate_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *preparent, struct iatt *postparent) { /* use this Function when a failure occurs, and delete the newly created file. */ trash_local_t *local = NULL; local = frame->local; if (op_ret == -1) { gf_log (this->name, GF_LOG_DEBUG, "deleting the newly created file: %s", strerror (op_errno)); } STACK_WIND (frame, trash_common_unwind_buf_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->truncate, &local->loc, local->fop_offset); return 0; } int32_t trash_truncate_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iovec *vector, int32_t count, struct iatt *stbuf, struct iobref *iobuf) { trash_local_t