Offline software archiver

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Mintmag

Offline software archiver

Post by Mintmag »

Hi there, so I've been working on this for a while now and would like to know what you guys think. I wrote a script in bash designed to make installing and running Mint offline or isolated much easier. Here's the script in question.

Debs for nividia drivers and crossover are included because I use those, but it should be easy to edit in and out the things you like. This script is meant for either fresh installs or live sessions of Linux Lint 18.2 Cinnamon.

Code: Select all

#!/bin/bash
# Message to users
echo "Use this script on either a freshly installed or live iso. Also you might want to switch to a local mirror"
# Main Folder name: "deb-mint-cin-18.2" 

# Creating main folder
cd ~/Desktop
sudo rm -vr deb-mint-cin-18.2
mkdir -p deb-mint-cin-18.2
cd ./deb-mint-cin-18.2

# Adding PPAs for Dolphin and Nvidia
sudo add-apt-repository ppa:dolphin-emu/ppa -y 
sudo add-apt-repository ppa:graphics-drivers/ppa -y

# Updating the system.
sudo apt-get update
sudo apt-get -o dir::cache::archives="./" -d dist-upgrade -y

# Grabbing codecs
sudo apt-get install mint-meta-codecs -y

# Getting apps
sudo apt-get -o dir::cache::archives="./" -d install --install-recommends \
vlc \
audacity \
-y

# Installing UK languge pack for Libreoffice
sudo apt-get -o dir::cache::archives="./" -d install --install-suggests libreoffice-help-en-gb -y


# Downloading packages from PPAs
sudo apt-get -o dir::cache::archives="./" -d install --install-recommends \
nvidia-384 \
dolphin-emu-master \
-y
# Cinnamon themes

# Mint X Mod
wget https://dl.opendesktop.org/api/files/download/id/1460968157/167869-mint-x-mod-bundle.tar.gz

# Mint Y Dark Blue
wget https://cinnamon-spices.linuxmint.com/files/themes/Mint-Y-Dark-Blue.zip

# Win 10 Light
wget https://cinnamon-spices.linuxmint.com/files/themes/Windows-10.zip 


# debs for Crossover 
# To know what the debs are install crossover with sudo gdebi crossover
wget http://crossover.codeweavers.com/redirect/crossover.deb
sudo apt-get -o dir::cache::archives="./" -d install gcc-5-base:i386 gcc-6-base:i386 libavahi-client3:i386 libavahi-common-data:i386 libavahi-common3:i386 libbsd0:i386 libc6 libc6-dbg libc6:i386 libcomerr2:i386 libcups2:i386 libdbus-1-3:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi6:i386 libfreetype6:i386 libgcc1:i386 libgcrypt20 libgcrypt20:i386 libgl1-mesa-dri:i386 libgl1-mesa-glx:i386 libglapi-mesa:i386 libglu1-mesa:i386 libgmp10:i386 libgnutls-openssl27 libgnutls30 libgnutls30:i386 libgpg-error0:i386 libgssapi-krb5-2:i386 libhogweed4:i386 libidn11:i386 libk5crypto3:i386 libkeyutils1:i386 libkrb5-3:i386 libkrb5support0:i386 liblcms2-2:i386 libllvm3.8:i386 liblzma5:i386 libnettle6:i386 libp11-kit0:i386 libpciaccess0:i386 libpcre3:i386 libpng12-0:i386 libselinux1:i386 libstdc++6:i386 libsystemd0:i386 libtasn1-6 libtasn1-6:i386 libtinfo5:i386 libudev1:i386 libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386 libxcb-dri3-0:i386 libxcb-glx0:i386 libxcb-present0:i386 libxcb-sync1:i386 libxcb1:i386 libxcursor1:i386 libxdamage1:i386 libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxi6:i386 libxrandr2:i386 libxrender1:i386 libxshmfence1:i386 libxxf86vm1:i386 zlib1g:i386 libnss-mdns:i386 \
-y

# Moving files to pacakge 
sudo tar -cvf Pkgs.tar *.deb *.zip *.gz --remove-files

# remving lock and partial
sudo rm -vr partial lock

# creating installer script
echo "#!/bin/bash

# Main address: '~/Desktop/TEMP'

# Making temp directory
sudo rm -vr ~/Desktop/TEMP
mkdir -v ~/Desktop/TEMP


# Moving packages to directory
sudo tar -xvf Pkgs.tar -C ~/Desktop/TEMP

# Moving command into directory
cd ~/Desktop/TEMP

# Installing packages (this is not a typo, this must be done twice)
sudo dpkg -i *.deb 
sudo dpkg -i *.deb


# Instralling themes
mkdir ~/.themes
unzip '*.zip' -d ~/.themes
tar -xvf 167869-mint-x-mod-bundle.tar.gz
cp -vr ~/Desktop/TEMP/mint-x-mod-bundle/mint-x-mod ~/.themes

# Deleting what's left.
cd ..
sudo rm -vr ./TEMP" >> ./Install.sh
sudo chmod +x ./Install.sh

Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
T_Characht3r

Re: Offline sotware archiver

Post by T_Characht3r »

Looks good! (don't take my word for it though). :)
ganamant
Level 4
Level 4
Posts: 384
Joined: Sun Mar 29, 2015 4:08 pm

Re: Offline software archiver

Post by ganamant »

I have a few suggestions:
  1. Instead of making multiple sudo calls from within the script, run the script itself as root. If you add the following code at the head of the script, the script will abort unless you invoke it as root.

    Code: Select all

    if [[ $EUID -ne 0 ]] ; then
        >/dev/stderr echo "This script must be run as root.
        exit 1
    fi
    
  2. Instead of hard-coding things like ppa:dolphin-emu/ppa, group them into an array constant at the head of the script and loop through that array. That way it will be easier to add or remove things later, to fix typos, etc.

    Code: Select all

    PPA_ARRAY=(
        ppa:dolphin-emu/ppa
        ppa:graphics-drivers/ppa
    )
    
    And later, you can call:

    Code: Select all

    for i in ${PPA_ARRAY[@]}; do
        add-apt-repository $i -y
    done
    
Locked

Return to “Scripts & Bash”