Skip to content

Commit

Permalink
Add new file upsize_box.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanways committed Dec 15, 2023
1 parent 5347b4c commit 7c6359f
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
53 changes: 53 additions & 0 deletions includes/resize_box.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/env bash
################################################################################
# Pandoras #
# #
# Universal Chroot environment that can be deployed to most Linux distros #
# #
# Change History #
# 12/11/2023 Esteban Herrera Original code. #
# Add new history entries as needed. #
# #
# #
################################################################################
################################################################################
################################################################################
# #
# Copyright (c) 2023-present Esteban Herrera C. #
# [email protected] #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #

# Resizes chroot
upsize_box() {

export dir=/var/pandoras

echo "Your chroot images:
$(ls $dir/images/ | sed 's/.img//g')
"
echo "🛑️ Danger: Stop ht ."
read -r -p "Type your chroot name: " chroot
read -r -p "Type the new chroot size (in GB): " size
#truncate -s "$size" "$dir"/images/"$chroot".img
qemu-img resize -f raw "$dir"/images/"$chroot".img "$size"G
e2fsck -f "$dir"/images/"$chroot".img
resize2fs "$dir"/images/"$chroot".img
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
(resize_box)
fi

52 changes: 52 additions & 0 deletions includes/upsize_box.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/env bash
################################################################################
# Pandoras #
# #
# Universal Chroot environment that can be deployed to most Linux distros #
# #
# Change History #
# 12/11/2023 Esteban Herrera Original code. #
# Add new history entries as needed. #
# #
# #
################################################################################
################################################################################
################################################################################
# #
# Copyright (c) 2023-present Esteban Herrera C. #
# [email protected] #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #

# Upsizes chroot
upsize_box() {

export dir=/var/pandoras

echo "Your chroot images:
$(ls $dir/images/ | sed 's/.img//g')
"
echo "Stop your chroot before continue!"
read -r -p "Type your chroot name: " chroot
read -r -p "Type the new chroot size (in GB): " size
qemu-img resize -f raw "$dir"/images/"$chroot".img "$size"G
e2fsck -f "$dir"/images/"$chroot".img
resize2fs "$dir"/images/"$chroot".img
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
(upsize_box)
fi

5 changes: 5 additions & 0 deletions pandoras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Boxes Options:
-duplicate-box Duplicates chroot
-enter-box Enters the chroot
-list-boxes Lists all the chroots
-upsize-box Upsizes chroot
Other Options:
-g, --license Print the GPL license notification
Expand Down Expand Up @@ -121,6 +122,10 @@ main() {
cd /var/pandoras/includes || { echo "Error: Unable to change directory."; exit 1; }
bash list_boxes.sh list_boxes || { echo "Error: list_boxes.sh failed."; exit 1; }
;;
'-upsize-box')
cd /var/pandoras/includes || { echo "Error: Unable to change directory."; exit 1; }
bash upsize_box.sh upsize_box || { echo "Error: upsize_box.sh failed."; exit 1; }
;;
'-g' | '--license')
display_license | more
exit 99
Expand Down

0 comments on commit 7c6359f

Please sign in to comment.