View Single Post
Old 12-11-2023, 02:48 PM   #74
crazyren
Junior Member
crazyren began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2023
Device: PW3
Lightbulb Ipkg.sh

Here is a little script to automate everything sorry for the multiple posts on an old thread but I can't seem to edit them.

Copy the script onto /mnt/us/ and make sure to chmod +x

[#] First run
Code:
./ipkg.sh
[#] After restart to mount only and export PATH
-m param i.e
Code:
./ipkg.sh -m
[#] Installing a package
Code:
ipkg -t /opt/tmp install nmap
[#]If you use a different console make sure to
Quote:
export PATH=$PATH:/opt/bin
Quote:
ipkg -t /opt/tmp update

Ipkg.sh
PHP Code:
#!/bin/bash

# Flag to determine whether to mount the existing ext3 image file
MOUNT_ONLY=false
# Set the path to the local.ext3 file
LOCAL_EXT3_FILE="/mnt/us/local.ext3"
# Set the size of the ext3 image file in megabytes
EXT3_IMAGE_SIZE=500
# Export PATH
export PATH=$PATH:/opt/bin

# Function to display script usage
show_usage() {
  echo 
"Usage: $0 [-m]"
  
echo "  -m   Mount the existing ext3 image file"
  
exit 1
}

# Process command-line options
while getopts ":m" opt; do
  case 
$opt in
    m
)
      
MOUNT_ONLY=true
      
;;
    \?)
      echo 
"Invalid option: -$OPTARG"
      
show_usage
      
;;
  
esac
done

# Function to create and copy the ext3 image file
create_ext3_image() {
  
dd if=/dev/zero of="$LOCAL_EXT3_FILEbs=1M count="$EXT3_IMAGE_SIZE"
  
mkfs.ext3 "$LOCAL_EXT3_FILE"
  
cp "$LOCAL_EXT3_FILE/media/Kindle
}

# Function to mount the ext3 image file
mount_ext3_image() {
  
mntroot rw
  mkdir 
-/mnt/loc
  mount 
-o loop,noatime -t ext3 "$LOCAL_EXT3_FILE/mnt/loc
  mkdir 
-/mnt/loc/opt/etc /mnt/loc/opt/share /mnt/loc/opt/lib /mnt/loc/opt/bin /mnt/loc/opt/tmp
  ln 
-/mnt/loc/opt/etc /opt/etc
  ln 
-/mnt/loc/opt/share /opt/share
  ln 
-/mnt/loc/opt/lib /opt/lib
  ln 
-/mnt/loc/opt/bin /opt/bin
  ln 
-/mnt/loc/opt/tmp /opt/tmp
  mntroot ro
}

# Function to install OptWare
install_optware() {
  
cd /opt/etc
  feed
="http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable"
  
wget "${feed}/ipkg-opt_0.99.163-10_arm.ipk"
  
tar -xOvzf ipkg-opt_0.99.163-10_arm.ipk ./data.tar.gz tar -/mnt/loc -xzvf -
  
mkdir -/opt/etc/ipkg
  
echo "src cross $feed> /opt/etc/ipkg/feeds.conf
  ipkg 
-/opt/tmp update
}

# Main script
if [ "$MOUNT_ONLYfalse ]; then
  create_ext3_image
  mount_ext3_image
  install_optware
fi

if [ "$MOUNT_ONLYtrue ]; then
  mount_ext3_image
fi 
.
crazyren is offline   Reply With Quote