mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2025-02-16 23:57:11 +00:00
EOF error, but it's complete (just needs to be tested)
This commit is contained in:
parent
2669d076b2
commit
4abc357cb4
1 changed files with 206 additions and 143 deletions
|
@ -3,20 +3,164 @@
|
|||
#
|
||||
# Papps_Installer for Plugapps
|
||||
# Works on *all* Plug devices (Pogoplug v1/2; Dockstar; Tonidoplug)
|
||||
# Version 0.5.1 # Halfie
|
||||
# Version 0.5.1 # Halfie (becomes 1.0 upon testing)
|
||||
#
|
||||
|
||||
###########################
|
||||
## Function Declarations ##
|
||||
###########################
|
||||
|
||||
function MD5 () {
|
||||
if [[ $(cat $2 | cut -d' ' -f1) != $(md5sum $1 | cut -d' ' -f1) ]]; then
|
||||
echo "Bad md5 detected on $1"
|
||||
exit 1
|
||||
fi
|
||||
# Introduction
|
||||
function Intro () {
|
||||
cat <<INTRO
|
||||
|
||||
<< Welcome to the PlugApps for Pogoplug v1/v2/DockStar USB Installer. >>
|
||||
|
||||
>> (Preferred) To install to usb (pogoplug v2) please use ./papps_installer --usb
|
||||
>> (Advanced) To install to nand please use ./papps_installer --nand
|
||||
---
|
||||
If you are lost, please ask for help, or risk bricking your plug.
|
||||
INTRO
|
||||
}
|
||||
|
||||
## Nand Install
|
||||
function Nand () {
|
||||
local FlashType=nand
|
||||
|
||||
cat <<NAND
|
||||
|
||||
For Advanced Users Only...
|
||||
>>> Tonido/Sheevaplug users press enter to continue
|
||||
>>> Pogoplug users please use the --usb installer (or continue at your own risk)
|
||||
|
||||
Press ENTER to continue...
|
||||
NAND
|
||||
read enter
|
||||
|
||||
# Let's give one final warning
|
||||
WarningNand
|
||||
|
||||
# Lets mount everything up & prepare
|
||||
cd /
|
||||
echo '---'; sleep 1 ; echo 'Mounting /dev/mtdblock3'
|
||||
mount -o rw,remount /
|
||||
mkdir -p /new_root
|
||||
umount /dev/mtdblock3
|
||||
mount /dev/mtdblock3 /new_root
|
||||
|
||||
# Clean everything out
|
||||
echo '---'; sleep 1; echo 'Cleaning /dev/mtdblock3'
|
||||
rm -rf /new_root/*
|
||||
|
||||
# Download the flash image & MD5 check
|
||||
echo '---'; sleep 1; echo 'Downloading/Checksumming Flash Image'
|
||||
Download
|
||||
echo '---'; sleep 1; echo 'Extracting Image'
|
||||
Extract
|
||||
echo '---'; sleep 1; echo 'Installing image'
|
||||
Install
|
||||
echo '---'; sleep 1; echo 'Modifying Boot Script (/etc/init.d/rcS)'
|
||||
ModifyrcS
|
||||
Reboot
|
||||
}
|
||||
|
||||
## USB Install
|
||||
function Usb () {
|
||||
local FlashType=usb
|
||||
|
||||
cat <<USB
|
||||
|
||||
Welcome to the USB installer (Preferred method of installation)...
|
||||
>>> Please start by removing all of your usb devices, and set aside one erasable disk
|
||||
|
||||
Press ENTER to continue...
|
||||
USB
|
||||
|
||||
# Lets give a final Warning
|
||||
WarningUsb
|
||||
|
||||
# Find the correct disk to format
|
||||
echo '---'; sleep 1 ; echo 'Listing Disks...'; echo ' ';
|
||||
ListDisk
|
||||
|
||||
# Decide & format disk
|
||||
Format
|
||||
|
||||
# Lets mount everything up & prepare
|
||||
cd /
|
||||
echo '---'; sleep 1 ; echo "Mounting /dev/$d"
|
||||
mount -o rw,remount /
|
||||
|
||||
# Shutdown hbmgr
|
||||
/etc/init.d/hbmgr.sh stop
|
||||
mkdir -p /new_root
|
||||
mount /dev/$d /new_root
|
||||
|
||||
# Clean everything out
|
||||
echo '---'; sleep 1; echo "Cleaning /dev/$d"
|
||||
rm -rf /new_root/*
|
||||
|
||||
# Download the flash image & MD5 check
|
||||
echo '---'; sleep 1; echo 'Downloading/Checksumming Flash Image'
|
||||
Download
|
||||
echo '---'; sleep 1; echo 'Extracting Image'
|
||||
Extract
|
||||
echo '---'; sleep 1; echo 'Installing image'
|
||||
Install
|
||||
echo '---'; sleep 1; echo 'Modifying Boot Script (/etc/init.d/rcS)'
|
||||
ModifyrcS
|
||||
Reboot
|
||||
}
|
||||
|
||||
function WarningNand () {
|
||||
cat <<WNAND
|
||||
If you have important data in /opt (aka /dev/mtdblock3), please backup before running this utility.
|
||||
...
|
||||
Are you sure you want to run a nand flash? [Y/n]
|
||||
WNAND
|
||||
|
||||
function WarningUsb () {
|
||||
cat <<WUSB
|
||||
If you have important data on your disk, please backup now. ALL DATA WILL BE ERASED!
|
||||
...
|
||||
Are you sure you want to run a usb install? [Y/n]
|
||||
WUSB
|
||||
|
||||
read item
|
||||
case "$item" in
|
||||
y*|Y*) ;;
|
||||
n|N) echo "Fine, don't continue!"; exit 1;;
|
||||
*) echo "Fail, please answer Y/n"; exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
# List availiable disks (just in case someone didn't read the directions & unplug)
|
||||
function ListDisk () {
|
||||
# List disks to format
|
||||
/sbin/fdisk -l | grep 'Disk /dev/sd' | awk '{print NR " "$2 " " $3 " MB" }'
|
||||
}
|
||||
|
||||
function Format () {
|
||||
local d=''
|
||||
|
||||
cat <<FORMAT
|
||||
If you saw more than one disk please select the correct one here:
|
||||
|
||||
Type the number of the disk (EG. '1 /dev/sda: 8086 MB' ; you would type '1'):
|
||||
FORMAT
|
||||
read item
|
||||
case "$item" in
|
||||
1) dd if=/dev/zero of=/dev/sda bs=512 count=1; /sbin/fdisk /dev/sda <<< $'n\np\n1\n\n\nw\n'; local d=sda ;;
|
||||
2) dd if=/dev/zero of=/dev/sdb bs=512 count=1; /sbin/fdisk /dev/sdb <<< $'n\np\n1\n\n\nw\n'; local d=sdb ;;
|
||||
3) dd if=/dev/zero of=/dev/sdc bs=512 count=1; /sbin/fdisk /dev/sdc <<< $'n\np\n1\n\n\nw\n'; local d=sdc ;;
|
||||
4) dd if=/dev/zero of=/dev/sdd bs=512 count=1; /sbin/fdisk /dev/sdd <<< $'n\np\n1\n\n\nw\n'; local d=sdd ;;
|
||||
5) dd if=/dev/zero of=/dev/sde bs=512 count=1; /sbin/fdisk /dev/sde <<< $'n\np\n1\n\n\nw\n'; local d=sde ;;
|
||||
6) dd if=/dev/zero of=/dev/sdf bs=512 count=1; /sbin/fdisk /dev/sdf <<< $'n\np\n1\n\n\nw\n'; local d=sdf ;;
|
||||
*) echo "You selected > 7, or inputed an incorrect number"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Download images & check
|
||||
function Download () {
|
||||
cd /new_root/
|
||||
|
||||
|
@ -50,155 +194,74 @@ function Download () {
|
|||
MD5 plugbox-pogoplug.tar.gz plugbox-pogoplug.tar.gz.MD5
|
||||
}
|
||||
|
||||
|
||||
function notDownload () {
|
||||
for f in Modules.tar.gz Modules.tar.gz.md5 uImage uImage.md5; do
|
||||
if [[ ! -f sheeva-$KVer-$f ]]; then
|
||||
|
||||
## Make sure wget is present ##
|
||||
if [[ -z "$(which wget)" ]]; then
|
||||
"Something is horribly wrong & you're missing wget"
|
||||
## Add auto-fetch wget here ##
|
||||
# MD5 hash check
|
||||
function MD5 () {
|
||||
if [[ $(cat $2 | cut -d' ' -f1) != $(md5sum $1 | cut -d' ' -f1) ]]; then
|
||||
echo "Bad md5 detected on $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Grab the files ##
|
||||
wget -c http://sheeva.with-linux.com/sheeva/$KVer/sheeva-$KVer-$f
|
||||
if [[ ! -f sheeva-$KVer-$f ]]; then
|
||||
"Unable to retrieve sheeva-$KVer-$f"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
MD5
|
||||
}
|
||||
|
||||
## Introduction
|
||||
|
||||
function Intro () {
|
||||
cat <<INTRO
|
||||
|
||||
<< Welcome to the PlugApps for Pogoplug v1/v2/DockStar USB Installer. >>
|
||||
|
||||
>> To install to nand please use ./papps_installer --nand
|
||||
>> To install to usb (pogoplug v2) please use ./papps_installer --usb
|
||||
---
|
||||
If you are lost, please ask for help, or risk bricking your plug.
|
||||
INTRO
|
||||
}
|
||||
|
||||
#function ListDisks () {}
|
||||
|
||||
#function Format () {}
|
||||
|
||||
function Nand () {
|
||||
local FlashType=nand
|
||||
|
||||
cat <<NAND
|
||||
|
||||
For Advanced Users Only...
|
||||
>>> Tonido/Sheevaplug users press enter to continue
|
||||
>>> Pogoplug users please use the --usb installer (or continue at your own risk)
|
||||
NAND
|
||||
read enter
|
||||
|
||||
# Let's give one final warning
|
||||
Warning
|
||||
|
||||
# Lets mount everything up & prepare
|
||||
cd /
|
||||
echo '---'; sleep 1 ; echo 'Mounting /dev/mtdblock3'
|
||||
#mount -o rw,remount /
|
||||
#mkdir -p /new_root
|
||||
#umount /dev/mtdblock3
|
||||
#mount /dev/mtdblock3 /new_root
|
||||
|
||||
# Just clean everything out
|
||||
echo '---'; sleep 1; echo 'Cleaning /dev/mtdblock3'
|
||||
#rm -rf /new_root/*
|
||||
|
||||
# Download the flash image & MD5 check
|
||||
echo '---'; sleep 1; echo 'Downloading/Checksumming Flash Image'
|
||||
Download
|
||||
}
|
||||
|
||||
function Warning () {
|
||||
cat <<WARNING
|
||||
If you have important data in /opt (aka /dev/mtdblock3), please backup before running this utility.
|
||||
...
|
||||
Are you sure you want to run a nand flash? [Y/n]
|
||||
WARNING
|
||||
|
||||
read item
|
||||
case "$item" in
|
||||
y*|Y*) ;;
|
||||
n|N) echo "Fine, don't continue!"; exit 1;;
|
||||
*) echo "Fail, please answer Y/n"; exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
function Usb () {
|
||||
# Making directories and cleaning out the USB drive
|
||||
cd /
|
||||
mount -o rw,remount /
|
||||
killall hbwd
|
||||
mkdir -p /new_root
|
||||
mount /dev/sda1 /new_root
|
||||
rm -rf /new_root/*
|
||||
#Extract
|
||||
fi
|
||||
}
|
||||
|
||||
function Extract () {
|
||||
tar -xzf plugbox-pogoplug.tar.gz
|
||||
tar -xzf plugbox-pogoplug.tar.gz -C /new_root/
|
||||
## place some variable for *.tar.gz & call in appropriate function (usb or nand)
|
||||
}
|
||||
|
||||
# Install the extracted tar
|
||||
function Install () {
|
||||
touch /plugapps
|
||||
if [ -f /root/.bash_profile ]; then
|
||||
rm /root/.bash_profile
|
||||
fi
|
||||
touch root/.bash_profile
|
||||
echo "export TERM=linux" > root/.bash_profile
|
||||
rm plugbox-pogoplug.tar.gz
|
||||
## add variable here too
|
||||
}
|
||||
|
||||
# Modify the default rcS (need to get rid of this & use default rc.conf)
|
||||
function ModifyrcS () {
|
||||
cd /etc/init.d
|
||||
mv rcS rcS.backup
|
||||
if [[ "$FlashType" == "nand" ]]; then
|
||||
wget http://plugapps.com/os/pogoplug/v1/rcS
|
||||
fi
|
||||
if [[ "$FlashType" == "usb" ]]; then
|
||||
wget http://plugapps.com/os/pogoplug/v2/rcS
|
||||
fi
|
||||
chmod 755 rcS
|
||||
cat <<MODRCS
|
||||
Would like to change your hostname or do other boot tweaks?
|
||||
edit: /etc/init.d/rcS
|
||||
MODRCS
|
||||
}
|
||||
|
||||
# Reboot (Hopefully everything went smoothly)
|
||||
function Reboot () {
|
||||
cat <<REBOOT
|
||||
Congrats, you've just flashed your device!
|
||||
You now need to reboot so that the changes can take effect.
|
||||
You will need to remove your previous ssh keys (on client) otherwise you won't be able to login.
|
||||
rm ~/.ssh/known_hosts
|
||||
|
||||
Log back in with:
|
||||
User: root
|
||||
Pass: ceadmin
|
||||
|
||||
If everything completed successfully you will be greeted with 'root@PlugApps' upon reboot.
|
||||
|
||||
Press ENTER to reboot...
|
||||
REBOOT
|
||||
read enter
|
||||
}
|
||||
|
||||
###############################
|
||||
## END Function Declarations ##
|
||||
###############################
|
||||
|
||||
#
|
||||
# Downloading and Extracting
|
||||
#
|
||||
|
||||
#wget http://plugapps.com/os/pogoplug/plugbox-pogoplug.tar.gz
|
||||
# "Extracting PlugBox OS. This may take a few minutes."
|
||||
#
|
||||
#mv new_root/* ./
|
||||
#rmdir new_root
|
||||
#touch plugapps
|
||||
#touch root/.bash_profile
|
||||
# "export TERM=linux" > root/.bash_profile
|
||||
#rm plugbox-pogoplug.tar.gz
|
||||
|
||||
|
||||
#
|
||||
# Modifying Boot Files
|
||||
#
|
||||
#cd /etc/init.d
|
||||
#mv rcS rcS.backup
|
||||
#wget http://plugapps.com/os/pogoplug/v2/rcS
|
||||
#chmod 755 rcS
|
||||
|
||||
|
||||
#
|
||||
# Rebooting
|
||||
#
|
||||
# "Your Pogoplug Needs to be Restarted."
|
||||
# "You will have to remove SSH keys on Linux/Mac OS X to log back in."
|
||||
# "Type 'rm ~/.ssh/known_hosts"
|
||||
# ""
|
||||
# "Also, to boot back into the regular Pogoplug installation, just remove the drive you installed PlugApps on and restart your device."
|
||||
# ""
|
||||
# "You'll notice PlugApps are ready when you login and see a root@PogoPlug prompt."
|
||||
# "Press ENTER to reboot."
|
||||
#read enter
|
||||
#/sbin/reboot
|
||||
|
||||
|
||||
if [[ $# < 1 ]]; then
|
||||
Intro
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -209,6 +272,6 @@ elif [[ "$1" == "--usb" ]]; then
|
|||
Usb
|
||||
|
||||
else
|
||||
Usage
|
||||
Intro
|
||||
exit 1
|
||||
fi
|
||||
fi
|
Loading…
Reference in a new issue