Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
7ca01f96
Commit
7ca01f96
authored
Jan 12, 2019
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rooter/add_group.sh
parent
902f3a4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
add_group.sh
rooter/add_group.sh
+57
-0
No files found.
rooter/add_group.sh
0 → 100755
View file @
7ca01f96
#!/bin/sh
# Добавляет пользователя на указанном хосте и копирует ему ключ.
# Если указан ID контейнера, то добавляет внутри указанного контейнера
# Args; username host [VEID | -l]
docmd
()
{
echo
"
\$
$@
"
"
$@
"
}
fatal
()
{
echo
-e
"Error:
$@
"
>
&2
exit
1
}
USERNAME
=
$1
HOST
=
$2
VEID
=
$3
GROUP
=
$4
Help
=
"Usage:
$0
USERNAME HOST {VEID | -l} GROUP
\n
HOST - from yours ssh alias
\n
VEID - container ID or 0 for host system"
if
[
"
$USERNAME
"
=
"-h"
]
;
then
echo
-e
"
$Help
"
exit
fi
if
[
-z
"
$USERNAME
"
]
||
[
-z
"
$HOST
"
]
||
[
-z
"
$VEID
"
]
;
then
fatal
"
$Help
"
fi
ssh
$HOST
echo
||
fatal
"Host
$HOST
is not sshed"
SUDO
=
[
"
$UID
"
=
0
]
||
SUDO
=
"sudo"
HOSTSUDO
=
$SUDO
SSHOPT
=
""
HSSH
=
/home/
$USERNAME
/.ssh
add_group_cmd
()
{
echo
"
$SUDO
usermod
$USERNAME
-a -G
$GROUP
"
}
# copy key in host system
if
[
-z
"
$VEID
"
]
||
[
"
$VEID
"
=
0
]
;
then
# FIXME: не работает на CentOS
docmd ssh
$SSHOPT
$HOST
"
$(
add_group_cmd
)
"
exit
fi
SUDO
=
ssh
$SSHOPT
$HOST
"
$HOSTSUDO
vzctl exec
$VEID
\"
$(
add_group_cmd
)
\"
"
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