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
b35ab879
Commit
b35ab879
authored
Aug 20, 2015
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve rooter scripts
parent
23d58f4b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
7 deletions
+41
-7
add_eterkey.sh
rooter/add_eterkey.sh
+3
-2
get_iptables.sh
rooter/get_iptables.sh
+5
-1
get_vzlist.sh
rooter/get_vzlist.sh
+33
-4
No files found.
rooter/add_eterkey.sh
View file @
b35ab879
...
...
@@ -32,7 +32,7 @@ if [ -z "$USERNAME" ] || [ -z "$HOST" ] || [ -z "$VEID" ]; then
fi
USERKEY
=
$(
ssh rooter@server
get
pubkey
$USERNAME
)
USERKEY
=
$(
ssh rooter@server pubkey
$USERNAME
)
[
-n
"
$USERKEY
"
]
||
fatal
"Can't get ssh key"
...
...
@@ -44,11 +44,12 @@ SUDO=
# FIXME: почему-то в cat не раскрывается тильда!
#ADDKEYCMD="useradd $USERNAME ; su - $USERNAME -c 'mkdir -p ~/.ssh ; chmod 700 ~/.ssh ; touch ~/.ssh/authorized_keys ; chmod 600 ~/.ssh/authorized_keys' ; cat >> /home/$USERNAME/.ssh/authorized_keys"
HSSH
=
/home/
$USERNAME
/.ssh
# TODO: исправить повторное добавление ключей
ADDKEYCMD
=
"
$SUDO
useradd
$USERNAME
;
$SUDO
su -
$USERNAME
-c 'mkdir -p
$HSSH
; chmod 700
$HSSH
; touch
$HSSH
/authorized_keys ; chmod 600
$HSSH
/authorized_keys' ; cat >>
$HSSH
/authorized_keys"
# copy key in host system
if
[
-z
"
$VEID
"
]
||
[
"
$VEID
"
=
0
]
;
then
echo
"Copy key for
$USERNAME
to
$HOST
"
echo
"Copy key for
$USERNAME
to
host
$HOST
"
echo
"
$USERKEY
"
| docmd ssh
$HOST
"
$ADDKEYCMD
"
ssh
$HOST
$SUDO
ls
/home/
$USERNAME
/.ssh
-l
#ssh -i $USERKEY $USERNAME@$HOST ls ~/.ssh -l
...
...
rooter/get_iptables.sh
View file @
b35ab879
...
...
@@ -10,6 +10,10 @@ fatal()
exit
1
}
fastssh
()
{
ssh
-o
"ControlMaster auto"
-o
"ControlPath ~/tmp/ssh_mux_%h_%p_%r"
-o
"ControlPersist 4h"
"
$@
"
}
SUDO
=
[
"
$UID
"
=
0
]
||
SUDO
=
"sudo"
...
...
@@ -19,4 +23,4 @@ shift
echo
"
$HOSTLIST
"
|
grep
-q
--
"
$HOST
"
||
fatal
"Unknown host
$HOST
. Call to the administrator."
ssh
"root@
$HOST
"
$SUDO
iptables
-L
-n
-t
nat |
grep
"^DNAT"
fast
ssh
"root@
$HOST
"
$SUDO
iptables
-L
-n
-t
nat |
grep
"^DNAT"
rooter/get_vzlist.sh
View file @
b35ab879
...
...
@@ -10,6 +10,33 @@ fatal()
exit
1
}
# 5 minutes cache
is_obsoleted
()
{
test
-z
"
$(
find
"
$1
"
-cmin
-5
2>/dev/null
)
"
}
get_log
()
{
echo
~/tmp/vzlist.
$1
.cache
}
get_log_wh
()
{
echo
~/tmp/vzlist.
$1
.wh.cache
}
print_is_not_obsoleted
()
{
is_obsoleted
"
$1
"
&&
return
1
cat
"
$1
"
}
fastssh
()
{
ssh
-o
"ControlMaster auto"
-o
"ControlPath ~/tmp/ssh_mux_%h_%p_%r"
-o
"ControlPersist 4h"
"
$@
"
}
[
"
$UID
"
=
0
]
||
fatal
"Run me only as root"
# name,description
...
...
@@ -58,19 +85,21 @@ SUDO=
if
[
-n
"
$PRINTIP
"
]
;
then
VEID
=
$((
$1
))
OPTIONS
=
"
$OPTIONS
-H -oip
$VEID
"
ssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
fast
ssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
exit
fi
if
[
-n
"
$PRINTHOSTNAME
"
]
;
then
VEID
=
$((
$1
))
OPTIONS
=
"
$OPTIONS
-H -ohostname
$VEID
"
ssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
fast
ssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
exit
fi
if
[
-n
"
$PRINTHOST
"
]
;
then
ssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
|
sed
-e
"s|no
$|
$HOST
|g"
-e
"s| DISABL| HOST |g"
print_is_not_obsoleted
$(
get_log_wh
$HOST
)
&&
exit
fastssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
|
sed
-e
"s|no
$|
$HOST
|g"
-e
"s| DISABL| HOST |g"
|
tee
$(
get_log_wh
$HOST
)
else
ssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
print_is_not_obsoleted
$(
get_log
$HOST
)
&&
exit
fastssh
"root@
$HOST
"
$SUDO
vzlist
$OPTIONS
|
tee
$(
get_log
$HOST
)
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