add
This commit is contained in:
118
notizen
Normal file → Executable file
118
notizen
Normal file → Executable file
@@ -21,3 +21,121 @@ StandardOutput=append:/var/log/vmstat.log
|
|||||||
VMSTAT_OPTS=-ntw
|
VMSTAT_OPTS=-ntw
|
||||||
VMSTAT_DELAY=3
|
VMSTAT_DELAY=3
|
||||||
VMSTAT_LOG=/var/log/vmstat.log
|
VMSTAT_LOG=/var/log/vmstat.log
|
||||||
|
|
||||||
|
###############################
|
||||||
|
#oneShort beispiel
|
||||||
|
#vorbereitung
|
||||||
|
cp -a /usr/share/doc /usr/share/doc2
|
||||||
|
#Unit
|
||||||
|
systemctl edit --full --force my_oneshot
|
||||||
|
[Unit]
|
||||||
|
Description=tar/untar doc2
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/tar -czf /usr/share/doc2.tgz /usr/share/doc2
|
||||||
|
ExecStart=/usr/bin/rm -r /usr/share/doc2
|
||||||
|
|
||||||
|
ExecStop=/usr/bin/tar -xvzf /usr/share/doc2.tgz
|
||||||
|
ExecStop=/bin/rm /usr/share/doc2.tgz
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
####################
|
||||||
|
#typen
|
||||||
|
#
|
||||||
|
#simple
|
||||||
|
#oneshot
|
||||||
|
#always
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#Ubunut optimieren
|
||||||
|
#rm /etc/iniramfs-tools/conf.d/resume
|
||||||
|
#update-initramfs -k all -u
|
||||||
|
#
|
||||||
|
#
|
||||||
|
systemd-cgtop besser als top
|
||||||
|
|
||||||
|
###############Unit mit Multiparameter
|
||||||
|
#
|
||||||
|
#Vorbereitung
|
||||||
|
/etc/default/vmstatd
|
||||||
|
VMOPTS=-ntw
|
||||||
|
VMLOG=/var/tmp/vmstatd.log
|
||||||
|
VMDELAY=10
|
||||||
|
#VMCOUNT=
|
||||||
|
# Unit
|
||||||
|
[Unit]
|
||||||
|
Description=VMStat Daemon
|
||||||
|
StartLimitIntervalSec=2 min
|
||||||
|
StartLimitBurst=3
|
||||||
|
OnFailure=trig.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=20
|
||||||
|
RestartForceExitStatus=SIGHUP
|
||||||
|
EnvironmentFile=/etc/default/vmstatd
|
||||||
|
ExecStart=/bin/sh -c "exec /usr/bin/vmstat $VMOPTS $VMDELAY $VMCOUNT >> $VMLOG"
|
||||||
|
########################
|
||||||
|
#Namespace
|
||||||
|
# Beispiel mit ip
|
||||||
|
#Namespace erzeugen
|
||||||
|
ls -l /proc/self/ns
|
||||||
|
ip netns add ns1
|
||||||
|
ip netns exec ns1 /bin/bash
|
||||||
|
ip l
|
||||||
|
ip a
|
||||||
|
exit
|
||||||
|
ip netns pids ns1
|
||||||
|
ls -l /run/netns
|
||||||
|
ip netns del ns1
|
||||||
|
|
||||||
|
#veth (virtuelles Netzwerkkabel)
|
||||||
|
#Shell isolieren
|
||||||
|
ip link add name veth1 type veth peer name veth2
|
||||||
|
ip l
|
||||||
|
ip netns add ns1
|
||||||
|
ip link set dev veth2 netns ns1
|
||||||
|
ip l set dev veth1 up
|
||||||
|
ip addr change 172.16.0.1/16 dev veth1
|
||||||
|
ip netns exec ns1 ip l set dev veth2 up
|
||||||
|
ip netns exec ns1 ip addr change 172.16.0.2/16 dev veth2
|
||||||
|
ping 172.16.0.2
|
||||||
|
ip netns exec ns1 /bin/bash
|
||||||
|
ip a
|
||||||
|
ip r
|
||||||
|
ping 172.16.0.1
|
||||||
|
ip l del dev veth1
|
||||||
|
ip netns del ns1
|
||||||
|
|
||||||
|
#isolierter ssh-Server
|
||||||
|
#Zwei Fenster, z.B. in tmux, links=server, rechts=client
|
||||||
|
|
||||||
|
ip link add name vethsrv0 type veth peer name vethcli0
|
||||||
|
ip netns add srv
|
||||||
|
ip netns add cli
|
||||||
|
ip link set vethsrv0 netns srv
|
||||||
|
ip link set vethcli0 netns cli
|
||||||
|
ip l
|
||||||
|
|
||||||
|
#Server (links)
|
||||||
|
ip netns exec srv /bin/bash
|
||||||
|
ip link set up dev vethsrv0
|
||||||
|
ip addr change 10.9.8.7/24 dev vethsrv0
|
||||||
|
|
||||||
|
#SSH Server starten
|
||||||
|
/sbin/sshd -dD
|
||||||
|
|
||||||
|
#Client (rechts)
|
||||||
|
ip netns exec cli /bin/bash
|
||||||
|
ip link set up dev vethcli0
|
||||||
|
ip addr change 10.9.8.6/24 dev vethcli0
|
||||||
|
|
||||||
|
#Connect
|
||||||
|
ip a
|
||||||
|
ssh 10.9.8.7
|
||||||
|
ip a
|
||||||
|
exit
|
||||||
|
####################################
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user