Last active
April 22, 2022 13:11
-
-
Save LordVeovis/03da6d5e39e0cc487b2da2218d0304ee to your computer and use it in GitHub Desktop.
Upgrade Alpine 3.15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # wget -O '/etc/local.d/upgrade-alpine-3.15.start' 'https://gist.github.com/LordVeovis/03da6d5e39e0cc487b2da2218d0304ee/raw/7468f5c31cd4d64094d9a2b59ef642967ba3f52c/upgrade-alpine-3.15.sh' | |
| # chmod +x /etc/local.d/upgrade-alpine-3.15.start | |
| CURRENT=3.14 | |
| NEXT=3.15 | |
| SCRIPT_ME=$PWD/$0 | |
| UPGRADE_LOCAL_SCRIPT=/etc/local.d/upgrade-alpine-3.15.start | |
| # identify current step | |
| go_step1=$(cat /etc/os-release | grep VERSION | grep $CURRENT | wc -l) | |
| go_step2=$(cat /etc/os-release | grep VERSION | grep $NEXT | wc -l) | |
| # === BEGIN TOOLS FUNCTIONS === | |
| function remove() { | |
| f=$1 | |
| if [ -f "$f" ]; then | |
| rm "$f" | |
| fi | |
| } | |
| function replace() { | |
| new=$1 | |
| old=$2 | |
| if [ -f "$new" ]; then | |
| mv "$new" "$old" | |
| fi | |
| } | |
| # === END TOOLS FUNCTIONS === | |
| function step1() { | |
| echo "|==========" | |
| echo "| ==> STEP1" | |
| echo "|==========" | |
| # suspend puppet | |
| rc-service puppet stop | |
| rc-update del puppet | |
| [ ! -f /etc/init.d/docker ] || rc-update del docker | |
| sed -i "s/$CURRENT/$NEXT/g" /etc/apk/repositories | |
| # remove old gems version | |
| gem uninstall -x puppet facter | |
| rc-update add local | |
| # upgrade the system | |
| apk update | |
| apk upgrade | |
| # reinstall puppet with the new ruby | |
| apk add --virtual=_build alpine-sdk ruby-dev | |
| gem install rdoc -v 6.3.3 --no-document | |
| gem install puppet -v 7.16.0 --no-document | |
| gem install msgpack CFPropertyList ruby-shadow --no-document | |
| apk del _build | |
| rm -r /usr/lib/ruby/gems/2.7.0 | |
| if [ "$SCRIPT_ME" -ne "$UPGRADE_LOCAL_SCRIPT" ]; then | |
| ln -fs "$SCRIPT_ME" "$UPGRADE_LOCAL_SCRIPT" | |
| fi | |
| reboot | |
| } | |
| function step2() { | |
| echo "|==========" | |
| echo "| ==> STEP2" | |
| echo "|==========" | |
| apk add diffutils | |
| rm "$UPGRADE_LOCAL_SCRIPT" | |
| if [ -f /etc/init.d/zabbix-agentd.apk-new ]; then | |
| mv /etc/init.d/zabbix-agentd.apk-new /etc/init.d/zabbix-agentd | |
| rc-service zabbix-agentd restart | |
| fi | |
| remove /etc/conf.d/loadkmap.apk-new | |
| remove /etc/conf.d/syslog.apk-new | |
| remove /etc/ssh/sshd_config.apk-new | |
| remove /etc/ssh/moduli.apk-new | |
| remove /etc/default/grub.apk-new | |
| remove /etc/hostname.apk-new | |
| remove /etc/fstab.apk-new | |
| remove /etc/shells.apk-new | |
| remove /etc/shadow.apk-new | |
| remove /etc/hosts.apk-new | |
| remove /etc/group.apk-new | |
| remove /etc/passwd.apk-new | |
| groupmems -g utmp -d utmp | |
| remove /etc/mkinitfs/mkinitfs.conf.apk-new | |
| remove /etc/conf.d/node-exporter.apk-new | |
| replace /etc/zabbix/zabbix_agentd.conf.apk-new /etc/zabbix/zabbix_agentd.conf | |
| puppet config set publicdir /var/lib/puppet/public | |
| rc-update add puppet | |
| [ ! -f /etc/init.d/docker ] || rc-update add docker | |
| reboot | |
| } | |
| if [ $go_step1 -eq 1 ]; then | |
| step1 | |
| fi | |
| if [ $go_step2 -eq 1 ]; then | |
| step2 | |
| fi | |
| function step3() { | |
| for f in $a; do | |
| org=$(echo $f|sed 's/.apk-new//') | |
| new=$f | |
| echo '' | |
| diff -u --color "$org" "$new" | |
| read | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment