Skip to content

Instantly share code, notes, and snippets.

@jhsea3do
Created June 14, 2020 03:55
Show Gist options
  • Save jhsea3do/aac3c513923a9631e1d700c4d5cca836 to your computer and use it in GitHub Desktop.
Save jhsea3do/aac3c513923a9631e1d700c4d5cca836 to your computer and use it in GitHub Desktop.
redhat-machine-init
#!/bin/sh
# SKIP first boot
MACHINE_ID="${MACHINE_ID:-9c06af6ff2f24f21ba291f8dc6dde14a}"
[ -f "/etc/machine-id.orig" ] && \
MACHINE_ID=$(cat /etc/machine-id.orig) && \
rm -rf /etc/machine-id.orig
[ "$(cat /etc/machine-id)" != "$MACHINE_ID" ] && \
exit 0
# https://unix.stackexchange.com/questions/437718/can-i-delete-70-persistent-net-rules
[ -f "/etc/udev/rules.d/70-persistent-net.rules" ] && \
rm -rf "/etc/udev/rules.d/70-persistent-net.rules"
# https://unix.stackexchange.com/questions/402999/it-is-ok-to-change-etc-machine-id
rm -f /etc/machine-id
dbus-uuidgen --ensure=/etc/machine-id
rm -f /var/lib/dbus/machine-id
dbus-uuidgen --ensure
# clean caches
rm -rf /tmp/aliyun_assist_*
rm -rf /tmp/go2*
rm -rf /tmp/grub*
rm -rf /opt/go2aliyun*
rm -rf /tmp/aliyun
rm -rf /root/.ssh
rm -rf /root/.gnupg
hwclock --hctosys
cat <<EOF | tee /etc/rc.d/rc.local > /dev/null
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
EOF
[ -f "$0" ] && \
rm -rf $0
rm -rf /etc/rc.d/init.d/boot.d
# https://www.cnblogs.com/flypig666/p/11741668.html
if [ -f "/root/.bash_history" ]; then
echo > /var/log/wtmp
echo > /var/log/btmp
echo > /var/log/lastlog
echo > /var/log/secure
echo > /var/log/messages
echo > /var/log/syslog
echo > /var/log/xferlog
echo > /var/log/auth.log
echo > /var/log/user.log
cat /dev/null > /var/adm/sylog
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/openwebmail.log
cat /dev/null > /var/log/mail.info
echo > /var/run/utmp
echo > /root/.bash_history
history -cw
fi
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
[ -f "/etc/rc.d/init.d/boot.d/00-init-first.sh" ]
sh /etc/rc.d/init.d/boot.d/00-init-first.sh
@jhsea3do
Copy link
Author

python get-pip.py

cat <<EOF | tee /tmp/r.txt
certifi==2020.4.5.2
chardet==3.0.4
Cheetah==2.4.4
cloud-init==0.7.9
configobj==4.7.2
decorator==3.4.0
ethtool==0.8
idna==2.9
iniparse==0.4
Jinja2==2.10
jsonpatch==1.25
jsonpointer==2.0
lxml==3.2.1
M2Crypto==0.21.1
Magic-file-extensions==0.2
Markdown==2.6.11
MarkupSafe==1.1.1
oauthlib==3.1.0
pciutils==1.7.3
perf==0.1
prettytable==0.7.2
pycurl==7.19.0
pygobject==3.22.0
pygpgme==0.3
pyliblzma==0.5.3
pyOpenSSL==0.13.1
python-dateutil==1.5
python-dmidecode==3.12.2
python-linux-procfs==0.4.9
pyudev==0.15
pyxattr==0.5.1
PyYAML==5.3.1
requests==2.23.0
rhnlib==2.5.65
rhsm==1.19.9
schedutils==0.4
six==1.15.0
slip==0.4.0
slip.dbus==0.4.0
subscription-manager==1.19.21
urlgrabber==3.10
urllib3==1.25.9
yum-metadata-parser==1.1.4
EOF

pip install -r /tmp/r.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment