Skip to content

Instantly share code, notes, and snippets.

@mikoloism
Created February 12, 2022 15:21
Show Gist options
  • Save mikoloism/5a00dac4be39a95db00637f41d110503 to your computer and use it in GitHub Desktop.
Save mikoloism/5a00dac4be39a95db00637f41d110503 to your computer and use it in GitHub Desktop.
The USB Flash Driver Auto-Run scripts
[autorun]
open = "./.@Autorun/.setup.sh"
label = MY_USB_NAME
icon = "./.@Autorun/icon.ico"
#!/bin/bash
# message-box 'msg-text' 'msg-icon[error/info]'
function msgbox () {
printf '\a'
if [[ $2 == 'error' || $2 == '--error' ]]; then
notify-send "Bash Terminal : " "$1" --urgency=critical;
else
notify-send "Bash Terminal : " "$1" --urgency=normal;
fi;
}
# help function
function help_func () {
clear
printf "\n\t---------------------------------------------------------"
printf "\n\t-----------------[ autorun-setup ]-----------------------"
printf "\n\t---------------------------------------------------------"
printf "\n\n"
printf "\n\tFor installing \`autorun-mode\` using bellow arguments : "
printf "\n\t\t -m, -mount, --mount, mount, "
printf "\n\t\t -i, -install, --install, install\tInstalling/Mount \`autorun-mode\` in USB Port"
printf "\n\t\t -v, -version, --version, version\tshow version of this script"
printf "\n\t\t -h, -help, --help, help\t\tshow help file and how usage of this script"
printf "\n\tExaple : "
printf "\n\t\tsetup.sh -i [label-name]"
printf "\n\t\tsetup.sh -m [label-name]"
printf "\n\n";
}
# version function
function version_func () {
clear
printf "\n\t---------------------------------------------------------"
printf "\n\t-----------------[ autorun-setup ]-----------------------"
printf "\n\t---------------------------------------------------------"
printf "\n\t-----------------[ version : 1.0 ]-----------------------"
printf "\n\t---------------------------------------------------------"
printf "\n\n";
}
# installing/mounting in usb port function
function install_func () {
cp -R "@Autorun/" "/media/$USER/$1/.@Autorun/"
cp -R "autorun.inf" "/media/$USER/$1/.autorun.inf"
cp -R "setup.sh" "/media/$USER/$1/.@Autorun/.setup.sh"
msgbox '> Installing Done! <';
}
# IF BLOCK'S
if [[ $1 == '-h' || $1 == '-help' || $1 == '--help' || $1 == 'help' ]]; then help_func;
# installing | mount
elif [[ $1 == '-i' || $1 == '-install' || $1 == '--install' || $1 == 'install' ]]; then install_func $2;
elif [[ $1 == '-m' || $1 == '-mount' || $1 == '--mount' || $1 == 'mount' ]]; then install_func $2;
# version
elif [[ $1 == '-v' || $1 == '-version' || $1 == '--version' || $1 == 'version' ]]; then version_func;
# something else | help
else help_func;
fi;
[autorun]
open = ./setup.bat
label = MY_USB_NAME
icon = ./@Autorun/icon.ico
@
echo off
title Autorun
color 02
cls
attrib +h +s +r "autorun.inf"
attrib +h +s +r "@Autorun"
move "setup.bat" "@Autorun\\setup.bat"
exit /b

You can use any image icon with ".ico" format and "icon" file name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment