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
Boxiang Sun
slapos.package
Commits
9f9ea659
Commit
9f9ea659
authored
May 01, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace default home path in /etc/passwd
Report error when no group name specifed
parent
bf5a1ade
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
13 deletions
+20
-13
windows/scripts/groupadd
windows/scripts/groupadd
+12
-8
windows/scripts/useradd
windows/scripts/useradd
+8
-5
No files found.
windows/scripts/groupadd
View file @
9f9ea659
...
@@ -30,12 +30,16 @@
...
@@ -30,12 +30,16 @@
#
#
ACTION
=
ADD
ACTION
=
ADD
GROUP_NAME
=
$1
GROUP_NAME
=
$1
net localgroup
"
${
GROUP_NAME
}
"
/
${
ACTION
}
if
[[
"
$GROUP_NAME
"
==
""
]]
;
then
if
((
$?
==
0
))
;
then
echo
Error: no group name specified.
if
[[
$ACTION
==
"ADD"
]]
;
then
exit
1
grep
-q
"^
${
GROUP_NAME
}
"
/etc/group
&&
sed
-i
-e
"/^
${
GROUP_NAME
}
/d"
/etc/group
fi
mkgroup |
grep
"^
${
GROUP_NAME
}
:"
>>
/etc/group
elif
[[
$ACTION
==
"DELETE"
]]
;
then
if
[[
$ACTION
==
"ADD"
]]
;
then
grep
-q
"^
${
GROUP_NAME
}
"
/etc/group
&&
sed
-i
-e
"/^
${
GROUP_NAME
}
/d"
/etc/group
NET LOCALGROUP
"
${
GROUP_NAME
}
"
/ADD
fi
grep
-q
"^
${
GROUP_NAME
}
"
/etc/group
&&
sed
-i
-e
"/^
${
GROUP_NAME
}
/d"
/etc/group
mkgroup |
grep
"^
${
GROUP_NAME
}
:"
>>
/etc/group
elif
[[
$ACTION
==
"DELETE"
]]
;
then
NET LOCALGROUP
"
${
GROUP_NAME
}
"
/DELETE
grep
-q
"^
${
GROUP_NAME
}
"
/etc/group
&&
sed
-i
-e
"/^
${
GROUP_NAME
}
/d"
/etc/group
fi
fi
windows/scripts/useradd
View file @
9f9ea659
...
@@ -45,8 +45,11 @@ while getopts "Dd:g:G:p:s:r" opt ; do
...
@@ -45,8 +45,11 @@ while getopts "Dd:g:G:p:s:r" opt ; do
d
)
d
)
USER_HOME
=
$OPTARG
USER_HOME
=
$OPTARG
;;
;;
g|G
)
g
)
USER_GROUP
=
$OPTARG
USER_INIT_GROUP
=
grp_
$OPTARG
;;
G
)
USER_OTHER_GROUP
=
grp_
$OPTARG
;;
;;
p
)
p
)
USER_PASSWORD
=
$OPTARG
USER_PASSWORD
=
$OPTARG
...
@@ -77,10 +80,10 @@ if (( $? == 0 )) ; then
...
@@ -77,10 +80,10 @@ if (( $? == 0 )) ; then
NET USER
"
${
USER_NAME
}
"
"
${
USER_PASSWORD
}
"
/ADD
NET USER
"
${
USER_NAME
}
"
"
${
USER_PASSWORD
}
"
/ADD
grep
-q
"^
${
USER_NAME
}
"
/etc/passwd
&&
sed
-i
-e
"/^
${
USER_NAME
}
/d"
/etc/passwd
grep
-q
"^
${
USER_NAME
}
"
/etc/passwd
&&
sed
-i
-e
"/^
${
USER_NAME
}
/d"
/etc/passwd
mkpasswd |
grep
"^
${
USER_NAME
}
:"
>>
/etc/passwd
mkpasswd |
grep
"^
${
USER_NAME
}
:"
>>
/etc/passwd
[[
$USER_HOME
==
"/home/
$USER_NAME
"
]]
||
sed
-i
-e
"s%:/home/
${
USER_NAME
}
:%:
${
USER_HOME
}
:%g"
/etc/passwd
[[
!
"
$USER_HOME
"
==
""
]]
&&
[[
!
-f
$USER_HOME
]]
&&
mkdir
-p
$USER_HOME
&&
chown
$USER_NAME
$USER_HOME
[[
!
"
$USER_HOME
"
==
""
]]
&&
[[
!
-f
$USER_HOME
]]
&&
mkdir
-p
$USER_HOME
&&
chown
$USER_NAME
$USER_HOME
if
[[
!
"
$USER_GROUP
"
==
""
]]
;
then
[[
"
$USER_INIT_GROUP
"
==
""
]]
||
NET LOCALGROUP
$USER_INIT_GROUP
$USER_NAME
/ADD
NET LOCALGROUP
$USER_GROUP
$USER_NAME
/ADD
[[
"
$USER_OTHER_GROUP
"
==
""
]]
||
NET LOCALGROUP
$USER_OTHER_GROUP
$USER_NAME
/ADD
fi
elif
[[
$ACTION
==
"DELETE"
]]
;
then
elif
[[
$ACTION
==
"DELETE"
]]
;
then
NET USER
"
${
USER_NAME
}
"
/DELETE
NET USER
"
${
USER_NAME
}
"
/DELETE
grep
-q
"^
${
USER_NAME
}
"
/etc/passwd
&&
sed
-i
-e
"/^
${
USER_NAME
}
/d"
/etc/passwd
grep
-q
"^
${
USER_NAME
}
"
/etc/passwd
&&
sed
-i
-e
"/^
${
USER_NAME
}
/d"
/etc/passwd
...
...
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