aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorNicolas Thill <nico@openwrt.org>2011-11-09 00:23:58 +0000
committerNicolas Thill <nico@openwrt.org>2011-11-09 00:23:58 +0000
commit1b025024d48d07294e975299ee8dbdc751e72121 (patch)
tree04dab6a5c047d1027c0d59900433d2bef59c1277 /package
parent95910adf11ce0eb3c5cfae4de02a334ff3126f7b (diff)
downloadupstream-1b025024d48d07294e975299ee8dbdc751e72121.tar.gz
upstream-1b025024d48d07294e975299ee8dbdc751e72121.tar.bz2
upstream-1b025024d48d07294e975299ee8dbdc751e72121.zip
package/base-files: /lib/functions.sh: add {group,user}_{add,exists} functions
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@28871 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rwxr-xr-xpackage/base-files/files/lib/functions.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 43ce60ee15..a89a3e91b0 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -389,6 +389,43 @@ __END_OF_WARNING__
}
+group_add() {
+ local name="$1"
+ local gid="$2"
+ local rc
+ [ -f "${IPKG_INSTROOT}/etc/group" ] || return 1
+ [ -n "$IPKG_INSTROOT" ] || lock /var/lock/group
+ echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group
+ rc=$?
+ [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group
+ return $rc
+}
+
+group_exists() {
+ grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/group
+}
+
+user_add() {
+ local name="${1}"
+ 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
+}
+
+
pi_include() {
if [ -f "/tmp/overlay/$1" ]; then
. "/tmp/overlay/$1"