Skip to content

Commit ff55377

Browse files
authored
Merge pull request #24 from SociOS-Linux/develop
Sociois: Updated to the latest version3.4
2 parents 22f14dd + 4428f27 commit ff55377

File tree

4 files changed

+70
-37
lines changed

4 files changed

+70
-37
lines changed

lib/create_vm.sh

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,67 @@
11
#!/bin/bash
2-
MACHINENAME="socios_vm_test"
3-
#Disk_location="/tmp/socios/$Server_name.vdi"
4-
#Image_file="/tmp/socios/ubuntu.iso"
2+
if [ -d socios ]; then
3+
rm -rf socios
4+
fi
5+
mkdir -p socios
6+
chmod -R 755 socios
7+
8+
echo "Copying the ISO Image to Root Path"
9+
10+
cp /tmp/socios/ubuntu.iso socios
11+
12+
# Destination to save the VDI File
13+
DESTINATION=socios/VirtualBoxVMs
14+
ISO=socios
15+
16+
# List available Guest OS on MAC Machine
17+
echo "Available Guest OS on MAC Machine "
18+
VBoxManage list ostypes | grep -i ubuntu
19+
20+
echo "Enter the VM name: "
21+
read MACHINENAME
522

623
#Creating virtual machine
724
echo "Creating a $MACHINENAME virtual machine"
8-
vboxmanage createvm --name $MACHINENAME --ostype "Ubuntu_64" --register --basefolder `pwd`
25+
vboxmanage createvm --name $MACHINENAME --ostype "Ubuntu_64" --register --basefolder $DESTINATION
926

1027
#Set memory and network
1128
echo "Setting up the memory and network for created $MACHINENAME virtual machine"
1229
VBoxManage modifyvm $MACHINENAME --ioapic on
1330
VBoxManage modifyvm $MACHINENAME --memory 4096
14-
vboxmanage modifyvm $MACHINENAME --vram 128
31+
vboxmanage modifyvm $MACHINENAME --vram 256
1532
VBoxManage modifyvm $MACHINENAME --nic1 nat
1633
vboxmanage modifyvm $MACHINENAME --cpus 4
1734
vboxmanage modifyvm $MACHINENAME --graphicscontroller VMSVGA
1835

1936
diskutil list
20-
echo "Select the partition disk to install the OS"
21-
22-
read -p "Provide the disk space want to use for Linux OS: " disk_input
23-
24-
disk=$(/dev/"$disk_input")
37+
echo "Enter the storage size"
38+
read -p "Enter the storage size in GB in numerals:" gb
39+
size=`expr $gb \* 1024`
2540

2641
#Create Disk and connect Debian Iso
27-
# VBoxManage createhd --filename `pwd`/$MACHINENAME/$MACHINENAME.vdi --size 40000 --format VDI
28-
VBoxManage internalcommands createrawvmdk -filename `pwd`/"$MACHINENAME"/$MACHINENAME.vmdk -rawdisk disk
29-
VBoxManage modifyvm "$MACHINENAME" --boot1 dvd --boot2 disk --boot3 none
42+
echo "Creating Virtual Hard Disk"
43+
VBoxManage createhd --filename $DESTINATION/$MACHINENAME/$MACHINENAME.vdi --size $size --format VDI --variant Standard
44+
45+
#Add Storage Controller to Virtual Machine
46+
VBoxManage storagectl $MACHINENAME --name "SATA Controller" --add sata --bootable on
3047

31-
#Configuration of virtual hard_disk
32-
VBoxManage storagectl "$MACHINENAME" --name "SATA Controller" --add sata --controller IntelAhci
33-
VBoxManage storageattach $MACHINENAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium `pwd`/$MACHINENAME/$MACHINENAME_DISK.vdi
48+
#Attach Virtual Hard Disk to Virtual Storage Controller
49+
VBoxManage storageattach $MACHINENAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium $DESTINATION/$MACHINENAME/$MACHINENAME.vdi
3450

35-
#Configuration of ISO_image
51+
#Add IDE Controller to Virtual Machine (To Later Connect ISO/CD/DVD)
3652
VBoxManage storagectl $MACHINENAME --name "IDE Controller" --add ide --controller PIIX4
37-
VBoxManage storageattach $MACHINENAME --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium `pwd`/ubuntu.iso
3853

39-
#Enable RDP
40-
VBoxManage modifyvm $MACHINENAME --vrde on
41-
VBoxManage modifyvm $MACHINENAME --vrdemulticon on --vrdeport 10001
54+
#Resize virtual machine (VDI and VHD)
55+
#VBoxManage modifyhd "$DESTINATION/$MACHINENAME/$MACHINENAME.vdi" −−resize 40000
56+
#This changes the size of the virtual hard drive to 40000 MB
57+
58+
#Attach ISO_image
59+
VBoxManage storageattach $MACHINENAME --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium $ISO/ubuntu.iso
60+
61+
#Start the Virtual Machine in Headless Mode
62+
VBoxManage startvm $MACHINENAME
63+
64+
#Resize the Virtualbox in VM
65+
VBoxManage setextradata "$MACHINENAME" GUI/ScaleFactor 2.5
4266

43-
#Start the VM
44-
VBoxHeadless --startvm $MACHINENAME
67+
echo "ISO image booted in Virtualbox.... Start setup process"

lib/disk_partition.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,31 @@ target_disk=$(diskutil list | awk '/Apple_APFS/ {print $7}')
66

77
echo "$target_disk"
88
default_disk=$target_disk
9-
default_size='40g'
9+
default_size=40
1010

1111
read -p "Click Yes to use the default disk for the partition, No to select custom disk (Yes\No):" choice
1212

1313
case "$choice" in
1414
Yes|yes|"") Input=1;;
15-
No|no) Input=0;;
1615
* ) { echo "Invalid option. Plesase select the correct option."; exit 1; };;
1716
esac
1817

18+
No|no) Input=0;;
1919
if [ $Input == 1 ]
2020
then
21-
echo "Resizing the APFS container for partition $default_disk $default_size"
22-
diskutil apfs resizeContainer $default_disk $default_size
21+
echo "Resizing the APFS container for partition named New_volume $default_disk $default_size"
22+
read -p "Provide the total space you find on the left side of the $target_disk in numerals(eg:100 for 100GB): " total_space
23+
crct_default_space="$(echo $total_space - $default_size | bc)"
24+
diskutil apfs resizeContainer "$default_disk" "$crct_default_space""g" jhfs+ New_volume "$default_size""g"
2325
else
2426
diskutil list
2527
echo "Provide the disk space want to use for the above list."
26-
read -p "Provide the disk space want to use for Linux OS: " disk_input
27-
read -p "Provide the disk space want to allocate for Linux OS in GB(e.g:30g): " size_input
28-
diskutil apfs resizeContainer "$disk_input" "$size_input"
28+
read -p "Provide the APFS container identifier you want to use for Linux OS(e.g:disk0s2): " disk_input
29+
read -p "Provide the total space you find on the left side of the provided identifier in numerals(eg:100 for 100GB): " total_space
30+
read -p "Provide a name for the volume of your wish: " name
31+
read -p "Provide the disk space want to allocate for Linux OS in numerals(e.g:30 for 30GB): " size_input
32+
crct_space="$(echo $total_space - $size_input | bc)"
33+
diskutil apfs resizeContainer "$disk_input" "$crct_space""g" jhfs+ "$name" "$size_input""g"
2934
fi
3035

3136
disk=$(/dev/"$disk_input")
@@ -41,4 +46,4 @@ $target_disk# GB boot parttion
4146
p # print the in-memory partition table
4247
w # write the partition table
4348
q # and we're done
44-
EOF
49+
EOF

lib/install_virtualbox.scpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ printf "Analyzing system application environment. Wait...\n" && sleep 2
33
if osascript -e 'id of application "virtualbox" ' >/dev/null 2>&1; then
44
printf "%s\n" "VirtualBox is available."
55
source $Cellar/*/lib/image.sh
6-
source $Cellar/*/lib/disk_partition.sh
76
else
87
printf "%s\n" "VirtualBox yet not installled. Need to install it."
98
read -p "Click Yes to install VirtualBox, No to end the process(Yes\No):" choice
@@ -19,7 +18,6 @@ if [ $vmInput == 1 ]; then
1918
brew install --cask virtualbox
2019
brew install --cask gdisk
2120
source $Cellar/*/lib/image.sh
22-
source $Cellar/*/lib/disk_partition.sh
2321
fi
2422

2523
if [ $vmInput == 0 ]; then

socios

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ function createvm {
1515

1616
#Uninstalling VirtualBox_VM
1717

18+
function unmount {
19+
source $Cellar/*/lib/disk_partition.sh
20+
}
21+
22+
#Uninstalling VirtualBox_VM
23+
1824
function purge {
1925
source $Cellar/*/lib/purge.sh
2026
}
@@ -23,14 +29,12 @@ function purge {
2329

2430
function help {
2531
echo "Socios - Linux with your Mac."
26-
echo "Usage: socios [options...]"
27-
echo
28-
echo "Valid options are:"
2932
echo "build Create the virtual machine in VirtualBox"
3033
echo "init Check the environment to install Socios"
3134
echo "--help Print this Help menu"
3235
echo "--version Print the current version"
33-
echo "purge Uninstall the Virtualbox and GDisk"
36+
echo "unmount unmount the current disk space in MAC Machine"
37+
echo "purge Uninstall the Virtualbox and GDisk"
3438
}
3539

3640
#Version of Socios formula
@@ -57,6 +61,9 @@ for arg in "$@"; do
5761
if [[ "$arg" = --version ]]; then
5862
version
5963
fi
64+
if [[ "$arg" = unmount ]]; then
65+
unmount
66+
fi
6067
if [[ "$arg" = purge ]]; then
6168
purge
6269
fi

0 commit comments

Comments
 (0)