try to get rootfs url automatically
This commit is contained in:
parent
3717d58dd0
commit
aa55c79205
2 changed files with 46 additions and 1 deletions
34
README.md
Normal file
34
README.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
# menhera.sh
|
||||
|
||||
Start a RAM Linux system (Debian for now) without requiring physical access to your server.
|
||||
|
||||
With menhera.sh you can:
|
||||
* format your system disk or create RAID
|
||||
* install a new distro
|
||||
* do important maintenance or backup with nobody writing to your root filesystem
|
||||
* ...
|
||||
|
||||
with only SSH!
|
||||
|
||||
"menhera" is short for "mental healer".
|
||||
|
||||
## Dependencies
|
||||
|
||||
* Linux kernel: overlayfs and tmpfs support
|
||||
* systemd
|
||||
* squashfs-tools
|
||||
* wget
|
||||
|
||||
## Usage
|
||||
|
||||
Just download and run.
|
||||
|
||||
## Known issues
|
||||
|
||||
* Cannot auto detect rootfs URL
|
||||
|
||||
## Thanks
|
||||
|
||||
* This project is inspired by [marcan/takeover.sh](https://github.com/marcan/takeover.sh)
|
||||
* The major code came from [a maintenance writeup on my blog](https://blog.swineson.me/debian-9-csm-online-convert-root-partition-to-raid/) (in Simp. Chinese)
|
||||
* [xTom.com](https://xtom.com/) donated a VPS for my testing
|
13
menhera.sh
13
menhera.sh
|
@ -3,7 +3,7 @@ set -Eeuo pipefail
|
|||
|
||||
# config
|
||||
WORKDIR="/tmp/menhera"
|
||||
ROOTFS="https://images.linuxcontainers.org/images/debian/stretch/amd64/default/20190409_05:24/rootfs.squashfs"
|
||||
ROOTFS=""
|
||||
|
||||
# internal global variables
|
||||
OLDROOT="/"
|
||||
|
@ -23,6 +23,16 @@ confirm() {
|
|||
esac
|
||||
}
|
||||
|
||||
get_rootfs() {
|
||||
if [ -z ${ROOTFS+x} ]; then
|
||||
echo "Getting rootfs URL..."
|
||||
ROOTFS_TIME=$(curl "https://uk.images.linuxcontainers.org/images/debian/stretch/amd64/default/?C=M;O=D" | grep "folder.gif" | head -n 1 | cut -d'>' -f7 | cut -d'/' -f1)
|
||||
ROOTFS="https://images.linuxcontainers.org/images/debian/stretch/amd64/default/${ROOTFS_TIME}/rootfs.squashfs"
|
||||
else
|
||||
echo "\$ROOTFS is set to '$ROOTFS'"
|
||||
fi
|
||||
}
|
||||
|
||||
sync_filesystem() {
|
||||
echo "Syncing..."
|
||||
sync
|
||||
|
@ -135,6 +145,7 @@ echo -e "\tYou have closed all programs you can, and backed up all important dat
|
|||
echo -e "\tYou can SSH into your system as root user"
|
||||
confirm || exit -1
|
||||
|
||||
get_rootfs
|
||||
sync_filesystem
|
||||
|
||||
prepare_environment
|
||||
|
|
Loading…
Reference in a new issue