mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
add autosizer source, modified README
This commit is contained in:
parent
df49b0d168
commit
c65b9daf1f
2 changed files with 28 additions and 13 deletions
|
@ -1,7 +1,18 @@
|
||||||
This folder contains helper script to build arm image for raspberry and derivative arm plateform.
|
This folder contains helper scripts to build an arm image for raspberry.
|
||||||
|
The files here are for builder. They are not needed to install yunohost.
|
||||||
|
|
||||||
the folder structure maps debian OS folders.
|
The folder structure maps debian OS folders, shell script here are helpers.
|
||||||
|
|
||||||
files are copied to the /root when finished.
|
The files are copied on the sdcard when installation is finished.
|
||||||
|
|
||||||
See also: https://yunohost.org/#/build_arm_image
|
See also: https://yunohost.org/#/build_arm_image for previous step.
|
||||||
|
|
||||||
|
run the following script before shuting down your rasbian.
|
||||||
|
|
||||||
|
~~~
|
||||||
|
./intsall_arm.sh
|
||||||
|
~~~
|
||||||
|
|
||||||
|
|
||||||
|
autosizer.sh is used on your PC to compact the dd image you will copy back.
|
||||||
|
this script requier root privilege to run and modify the sdcard image.
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Automatic Image file resizer
|
# Automatic Image file resizer
|
||||||
# Written by SirLagz
|
# Written by SirLagz
|
||||||
|
#
|
||||||
|
# got from: http://sirlagz.net/2013/03/10/script-automatic-rpi-image-downsizer/
|
||||||
|
|
||||||
strImgFile=$1
|
strImgFile=$1
|
||||||
|
|
||||||
if [[ ! $(whoami) =~ "root" ]]; then
|
if [[ ! $(whoami) =~ "root" ]]; then
|
||||||
|
@ -12,20 +15,20 @@ if [[ ! $(whoami) =~ "root" ]]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $strImgFile ]]; then
|
||||||
echo "Usage: ./autosizer.sh <Image File>"
|
echo "Usage: ./autosizer.sh <Image File>"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e $1 || ! $(file $1) =~ "x86" ]]; then
|
if [[ ! -e $strImgFile || ! $(file $strImgFile) =~ "x86" ]]; then
|
||||||
echo "Error : Not an image file, or file doesn't exist"
|
echo "Error : Not an image file, or file doesn't exist"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
partinfo=`parted -m $1 unit B print`
|
partinfo=`parted -m $strImgFile unit B print`
|
||||||
partnumber=`echo "$partinfo" | grep ext4 | awk -F: ' { print $1 } '`
|
partnumber=`echo "$partinfo" | grep ext4 | awk -F: ' { print $strImgFile } '`
|
||||||
partstart=`echo "$partinfo" | grep ext4 | awk -F: ' { print substr($2,0,length($2)-1) } '`
|
partstart=`echo "$partinfo" | grep ext4 | awk -F: ' { print substr($2,0,length($2)-1) } '`
|
||||||
loopback=`losetup -f --show -o $partstart $1`
|
loopback=`losetup -f --show -o $partstart $strImgFile`
|
||||||
e2fsck -f $loopback
|
e2fsck -f $loopback
|
||||||
minsize=`resize2fs -P $loopback | awk -F': ' ' { print $2 } '`
|
minsize=`resize2fs -P $loopback | awk -F': ' ' { print $2 } '`
|
||||||
minsize=`echo $minsize+1000 | bc`
|
minsize=`echo $minsize+1000 | bc`
|
||||||
|
@ -34,7 +37,8 @@ sleep 1
|
||||||
losetup -d $loopback
|
losetup -d $loopback
|
||||||
partnewsize=`echo "$minsize * 4096" | bc`
|
partnewsize=`echo "$minsize * 4096" | bc`
|
||||||
newpartend=`echo "$partstart + $partnewsize" | bc`
|
newpartend=`echo "$partstart + $partnewsize" | bc`
|
||||||
part1=`parted $1 rm 2`
|
# TODO: 2 is probably $partnumber
|
||||||
part2=`parted $1 unit B mkpart primary $partstart $newpartend`
|
part1=`parted $strImgFile rm 2`
|
||||||
endresult=`parted -m $1 unit B print free | tail -1 | awk -F: ' { print substr($2,0,length($2)-1) } '`
|
part2=`parted $strImgFile unit B mkpart primary $partstart $newpartend`
|
||||||
truncate -s $endresult $1
|
endresult=`parted -m $strImgFile unit B print free | tail -1 | awk -F: ' { print substr($2,0,length($2)-1) } '`
|
||||||
|
truncate -s $endresult $strImgFile
|
||||||
|
|
Loading…
Add table
Reference in a new issue