All Projects → antitoine → Lxd Functions

antitoine / Lxd Functions

Licence: mit
Simple script to mount LXD container and match host user with container user (uid/gid)

Programming Languages

shell
77523 projects
bash
514 projects

Projects that are alternatives of or similar to Lxd Functions

perl-scripts
A nice collection of day-to-day Perl scripts.
Stars: ✭ 92 (+736.36%)
Mutual labels:  utils, scripts
Dotfiles
My dotfiles 🚀. Includes configs for neovim, tmux, zsh, alacritty and more.
Stars: ✭ 47 (+327.27%)
Mutual labels:  scripts, zsh
basalt
The rock-solid Bash package manager
Stars: ✭ 16 (+45.45%)
Mutual labels:  zsh, scripts
Dotfiles
Awesome personal dotfiles
Stars: ✭ 99 (+800%)
Mutual labels:  scripts, zsh
Dotfiles
My dotfiles.
Stars: ✭ 5 (-54.55%)
Mutual labels:  scripts, zsh
Atom One Dark Terminal
A Terminal theme that mimics the One Dark theme made by the Atom team.
Stars: ✭ 890 (+7990.91%)
Mutual labels:  zsh
Dotfiles
My personal dotfiles
Stars: ✭ 24 (+118.18%)
Mutual labels:  zsh
Pctl
zsh plugin for proxy
Stars: ✭ 6 (-45.45%)
Mutual labels:  zsh
My Zsh Config
My custom Oh My Zsh configuration.
Stars: ✭ 5 (-54.55%)
Mutual labels:  zsh
Pythoncrawler
💗用python编写的爬虫项目集合
Stars: ✭ 856 (+7681.82%)
Mutual labels:  scripts
Dockerized lara
Build your Laravel App with Redis - Mongodb - MariaDB - Nginx - php7 - zsh
Stars: ✭ 9 (-18.18%)
Mutual labels:  zsh
Myjdbc Rainbow
jpa--轻量级orm模式对象与数据库映射api
Stars: ✭ 23 (+109.09%)
Mutual labels:  utils
Sepshell
Clean and minimal zsh theme with git bisecting/merging/rebasing modes and configurable prompt symbols.
Stars: ✭ 17 (+54.55%)
Mutual labels:  zsh
Distro.tools
Mirror
Stars: ✭ 25 (+127.27%)
Mutual labels:  scripts
Sneaky Scripts
Automated setup of development environments and other miscellaneous scripts.
Stars: ✭ 7 (-36.36%)
Mutual labels:  scripts
Mongodb Utils
MongoDB utils library for Node.js
Stars: ✭ 9 (-18.18%)
Mutual labels:  utils
Initubuntu
ShellScript use to Init Ubuntu
Stars: ✭ 24 (+118.18%)
Mutual labels:  zsh
Zsh History To Fish
Bring your ZSH history to Fish shell.
Stars: ✭ 23 (+109.09%)
Mutual labels:  zsh
Dotfiles
🔘 neovim, zsh, tmux, iTerm2, macOS dotfiles
Stars: ✭ 7 (-36.36%)
Mutual labels:  zsh
Takumi
Takumi, clean and elegant dotfiles
Stars: ✭ 22 (+100%)
Mutual labels:  zsh

lxd-functions

This bash file allows you to create, start and delete an LXD container. The goal is to mount the container with appropriate rights and ownership (with bindfs). After container started, you can work directly on the host machine, the current user is used in the mounted point and you have full access to it. In the container, a default user is used to map with the host user.

Dependencies

  • bindfs : the bash package to make advanced mounted directory (in ubuntu sudo apt-get install bindfs)

Installation

Clone this repository in /path/to/lxd-functions

Add in the .bashrc file (/home/<me>/.bashrc) or in the .profile :

if [ -f /path/to/lxd-functions/main.sh ]; then
  . /path/to/lxd-functions/main.sh
fi

Copy the example of configration file /path/to/lxd-functions/config.sh.example to /path/to/lxd-functions/config.sh and edit it, specially check that :

  • LXD_SOURCE_DIR need to match with the path of LXD containers in your system
  • LXD_MOUNT_DIR, it's where containers will be mounted. The default value is /var/lxd. It will be automaticaly created if you run the script.

To allow bash-completion to work, you need to give read access of the /var/lib/lxd/containers like this : sudo chmod ugo+r /var/lib/lxd/containers/

No need to change an existing LXD container, this script use the LXD API without container modification !

Commands

Commands available:

  • lxd-start <container name> (Start an LXD container and mount it)
  • lxd-stop <container name> (Stop an LXD container and umount it)
  • lxd-bindfs-mount <container name> <host user> <host group> <guest user> <guest group> (Mount an LXD Container)
  • lxd-bindfs-umount <container name> (Umount an LXD Container)
  • More soon (for example lxd-create ...)

Example of use

In this example, you already have a LXD named mylxd (started or not, it doesn't matter) and you let the default configuration (in the config.sh). Before working with it, just enter this : lxd-start mylxd The script will start LXD container (with lxc start mylxd), then try to mount the container in this path : /var/lxd/mylxd, if the directory mylxd isn't already present, the script will ask if you agree to create it automatically. That's all ! You can try to create files directly in the container or in the mounted directory, the file created will have the current user uid/gid in the host and the default user in the container.

The command lxd-stop mylxd is not required, but it will shutdown the lxd and unmount it for you.

Others commands are not needed too, this is for advanced use.

Questions ? Want to involve ?

Just ask in the issue section if it's not already done ;)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].