- local pid="${2:-$(pidof "$name")}"
- local grace="${3:-5}"
-
- [ -f "$pid" ] && pid="$(head -n1 "$pid" 2>/dev/null)"
-
- for pid in $pid; do
- [ -d "/proc/$pid" ] || continue
- local try=0
- kill -TERM $pid 2>/dev/null && \
- while grep -qs "$name" "/proc/$pid/cmdline" && [ $((try++)) -lt $grace ]; do sleep 1; done
- kill -KILL $pid 2>/dev/null && \
- while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done
- done
+ local uid="${2}"
+ local gid="${3:-$2}"
+ local desc="${4:-$1}"
+ local home="${5:-/var/run/$1}"
+ local shell="${6:-/bin/false}"
+ local rc
+ [ -f "${IPKG_INSTROOT}/etc/passwd" ] || return 1
+ [ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
+ echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd
+ rc=$?
+ [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
+ return $rc
+}
+
+user_exists() {
+ grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd