Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.package
Commits
bf5a1ade
Commit
bf5a1ade
authored
May 01, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user home when create user
parent
799a7d12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
18 deletions
+33
-18
windows/scripts/groupadd
windows/scripts/groupadd
+2
-1
windows/scripts/useradd
windows/scripts/useradd
+31
-17
No files found.
windows/scripts/groupadd
View file @
bf5a1ade
...
...
@@ -33,8 +33,9 @@ GROUP_NAME=$1
net localgroup
"
${
GROUP_NAME
}
"
/
${
ACTION
}
if
((
$?
==
0
))
;
then
if
[[
$ACTION
==
"ADD"
]]
;
then
grep
-q
"^
${
GROUP_NAME
}
"
/etc/group
&&
sed
-i
-e
"/^
${
GROUP_NAME
}
/d"
/etc/group
mkgroup |
grep
"^
${
GROUP_NAME
}
:"
>>
/etc/group
elif
[[
$ACTION
==
"DELETE"
]]
;
then
sed
-i
-e
"s/^
${
GROUP_NAME
}
:.*//g
"
/etc/group
grep
-q
"^
${
GROUP_NAME
}
"
/etc/group
&&
sed
-i
-e
"/^
${
GROUP_NAME
}
/d
"
/etc/group
fi
fi
windows/scripts/useradd
View file @
bf5a1ade
...
...
@@ -29,12 +29,13 @@
# Simulate the command useradd to add a user on the Cygwin
# useradd -d path -g init-group -s /bin/false -G group NAME
#
# -g, --gid GROUP
# The group name or number of the user's new initial login group. The group must exist.
# -g, --gid GROUP
# The group name or number of the user's new initial login group. The group must exist.
#
# -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
# A list of supplementary groups which the user is also a member of.
# -s
# -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
# A list of supplementary groups which the user is also a member of.
#
# -s
# Shell used by user
#
ACTION
=
ADD
...
...
@@ -42,34 +43,47 @@ ACTION=ADD
while
getopts
"Dd:g:G:p:s:r"
opt
;
do
case
$opt
in
d
)
USER_HOME
=
$OPTARG
;;
USER_HOME
=
$OPTARG
;;
g|G
)
USER_GROUP
=
$OPTARG
;;
USER_GROUP
=
$OPTARG
;;
p
)
USER_PASSWORD
=
$OPTARG
;;
;;
s
)
;;
r
)
;;
r
)
;;
*
)
echo
Error when add user
in
the Cygwin
exit
1
;;
exit
1
;;
esac
done
shift
$((
$OPTIND
-
1
))
USER_NAME
=
$1
net user
"
${
USER_NAME
}
"
"
${
USER_NAME
}
"
/
${
ACTION
}
if
[[
"
$USER_NAME
"
==
""
]]
;
then
echo
Error: no user name specified.
exit
1
fi
USER_HOME
=
${
USER_HOME
:
=/home/
$USER_NAME
}
USER_PASSWORD
=
${
USER_PASSWORD
:
=
$USER_NAME
}
if
((
$?
==
0
))
;
then
if
[[
$ACTION
==
"ADD"
]]
;
then
NET USER
"
${
USER_NAME
}
"
"
${
USER_PASSWORD
}
"
/ADD
grep
-q
"^
${
USER_NAME
}
"
/etc/passwd
&&
sed
-i
-e
"/^
${
USER_NAME
}
/d"
/etc/passwd
mkpasswd |
grep
"^
${
USER_NAME
}
:"
>>
/etc/passwd
[[
!
"
$USER_HOME
"
==
""
]]
&&
[[
!
-f
$USER_HOME
]]
&&
mkdir
-p
$USER_HOME
&&
chown
$USER_NAME
$USER_HOME
if
[[
!
"
$USER_GROUP
"
==
""
]]
;
then
NET LOCALGROUP
$USER_GROUP
$USER_NAME
/ADD
fi
elif
[[
$ACTION
==
"DELETE"
]]
;
then
sed
-i
-e
"s/^
${
USER_NAME
}
:.*//g"
/etc/passwd
NET USER
"
${
USER_NAME
}
"
/DELETE
grep
-q
"^
${
USER_NAME
}
"
/etc/passwd
&&
sed
-i
-e
"/^
${
USER_NAME
}
/d"
/etc/passwd
[[
!
"
$USER_HOME
"
==
""
]]
&&
[[
-f
$USER_HOME
]]
&&
rm
-rf
$USER_HOME
fi
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment