File: gentestdata.sh

package info (click to toggle)
libnss-cache 0.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212 kB
  • sloc: ansic: 1,701; makefile: 137; sh: 38
file content (28 lines) | stat: -rwxr-xr-x 804 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
set -e -u

export LC_ALL=C.UTF-8

outdir="$1"

for _i in `seq 1 2500` ; do
    uid=$(tr -cd [:alpha:] < /dev/urandom | head -c8)
    name=$(tr -cd [:alpha:] < /dev/urandom | head -c32)
    printf "%s:x:%d:1000:%s:/home/%s:/bin/nologin\n" "$uid" $_i "$name" "$uid"
done > "${outdir}/passwd.cache"

for _i in `seq 1 2500` ; do
    gid=$(tr -cd [:alpha:] < /dev/urandom | head -c8)
    name=$(tr -cd [:alpha:] < /dev/urandom | head -c32)
    printf "%s:x:%d:\n" "$gid" $_i
done > "${outdir}/group.cache"

while read line ; do
    uid=$(echo $line | cut -f1 -d:)
    printf "%s::::::::\n" $uid
done < "${outdir}/passwd.cache" > "${outdir}/shadow.cache"

while read line ; do
    gid=$(echo $line | cut -f1 -d:)
    printf "%s:::\n" $gid
done < "${outdir}/group.cache" > "${outdir}/gshadow.cache"