Browse Source

miaou-create install mandatory packages for miaou-bash

main
pvincent 3 weeks ago
parent
commit
fdb61e5949
  1. 3
      .vscode/settings.json
  2. 38
      bin/pct-destroy
  3. 1
      install.sh
  4. 31
      tools/miaou-create

3
.vscode/settings.json

@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}

38
bin/pct-destroy

@ -3,26 +3,41 @@
# CONSTANTS
BASEDIR=$(dirname "$0")
CONTAINER_NAME=$1
FORCE=$2
CONTAINER_NAME=''
FORCE=false
# FUNCTIONS
function usage {
echo "$(basename "$0") <CONTAINER_NAME> --force"
echo "$(basename "$0") <CONTAINER_NAME> [--force|-f]"
}
function set_force {
if [[ $FORCE == '--force' ]]; then
force=true
else
force=false
fi
function parse_options {
while [[ $# -gt 0 ]]; do
case "$1" in
--help | -h)
usage && exit 0
;;
--force | -f)
FORCE=true
;;
*)
if [[ -z $CONTAINER_NAME ]]; then
CONTAINER_NAME=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac
shift 1 # Move to the next argument
done
[[ -n $CONTAINER_NAME ]] || (usage && exit 1)
}
function destroy {
if vmid=$($BASEDIR/pct-lookup "$CONTAINER_NAME"); then
[[ $FORCE ]] && pct stop $vmid
[[ $FORCE == true ]] && pct stop $vmid
pct destroy $vmid
else
exit 1
@ -32,6 +47,5 @@ function destroy {
# MAIN
set -Eue
[[ "$#" -lt 1 ]] && usage && exit 1
set_force
parse_options $*
destroy

1
install.sh

@ -32,6 +32,7 @@ function install_miaou_proxmox {
if [[ ! -d /opt/miaou-proxmox ]]; then
echo 'installing miaou-proxmox...'
git clone https://git.artcode.re/miaou/miaou-proxmox.git /opt/miaou-proxmox
apt-get install -y shfmt
else
cd /opt/miaou-proxmox
git pull

31
tools/miaou-create

@ -14,22 +14,21 @@ function usage {
function parse_options {
while [[ $# -gt 0 ]]; do
case "$1" in
--help | -h)
usage && exit 0
;;
*)
if [[ -z $CONTAINER ]]; then
CONTAINER=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
--help | -h)
usage && exit 0
;;
*)
if [[ -z $CONTAINER ]]; then
CONTAINER=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac
shift 1 # Move to the next argument
done
[[ -n $CONTAINER ]] || (usage && exit 1)
}
function before_start {
@ -43,16 +42,18 @@ function before_start {
function after_start {
# hot changes
pct exec "$CONTAINER_ID" -- apt-get purge -y postfix
pct exec "$CONTAINER_ID" -- apt-get update
pct exec "$CONTAINER_ID" -- apt-get install -y file git bc vim jq sudo bash-completion
if [[ -v MIAOU_BASH_DIR ]]; then
pct exec "$CONTAINER_ID" -- /opt/miaou-bash/install.sh
pct exec "$CONTAINER_ID" -- /opt/miaou-bash/init.sh
fi
pct exec "$CONTAINER_ID" -- apt-get purge -y postfix
pct exec "$CONTAINER_ID" -- apt-get update
pct exec "$CONTAINER_ID" -- apt-get install -y sudo
}
function create {
CONTAINER_ID=$(pct-create $CONTAINER --no-start | grep "container: $CONTAINER succesfully created" | cut -d= -f2 | cut -d! -f1)
[[ -z $CONTAINER_ID ]] && echo -e "Unable to create container: $CONTAINER\nMight already exists?" && exit 10
before_start
pct start $CONTAINER_ID
after_start

Loading…
Cancel
Save