diff --git a/ct/atuin.sh b/ct/atuin.sh new file mode 100644 index 00000000000..430e1f039b3 --- /dev/null +++ b/ct/atuin.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: jager +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/atuinsh/atuin + +APP="Atuin Server" +var_tags="shell-history;server" +var_cpu="2" +var_ram="2048" +var_disk="8" +var_os="debian" +var_version="12" +var_unprivileged="1" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /usr/local/bin/atuin ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + # Get latest version from GitHub releases + LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/atuinsh/atuin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + CURRENT_VERSION=$(atuin --version | awk '{print $2}') + + if [[ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]]; then + msg_info "Stopping Atuin Server" + systemctl stop atuin-server + msg_ok "Stopped Atuin Server" + + msg_info "Updating $APP to v${LATEST_VERSION}" + # Download and run the official setup script + curl -fsSL https://setup.atuin.sh | sh + # Update the symlink + ln -sf ~/.atuin/bin/atuin /usr/local/bin/atuin + msg_ok "Updated $APP to v${LATEST_VERSION}" + + msg_info "Starting Atuin Server" + systemctl start atuin-server + msg_ok "Started Atuin Server" + else + msg_ok "No update required. ${APP} is already at v${CURRENT_VERSION}" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW}Your Atuin server is now running at:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8888${CL}" +echo -e "${INFO}${YW}To connect clients to this server:${CL}" +echo -e "${TAB}${BYW}atuin settings update sync_address http://${IP}:8888${CL}" +echo -e "${TAB}${BYW}atuin register --username --password ${CL}" +echo -e "${INFO}${YW}See ~/atuin-server-info.txt for detailed configuration options.${CL}" diff --git a/frontend/public/json/atuin.json b/frontend/public/json/atuin.json new file mode 100644 index 00000000000..16c2de05ed5 --- /dev/null +++ b/frontend/public/json/atuin.json @@ -0,0 +1,77 @@ +{ + "name": "Atuin Server", + "slug": "atuin-server", + "categories": [ + 12, + 8 + ], + "date_created": "2024-06-11", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 8888, + "documentation": "https://docs.atuin.sh/self-hosting/server-setup/", + "website": "https://atuin.sh/", + "logo": "https://raw.githubusercontent.com/atuinsh/atuin/main/assets/logo.png", + "config_path": "/etc/atuin/server.toml", + "description": "Atuin Server provides a self-hosted sync service for the Atuin shell history tool. It stores your shell history in a PostgreSQL database and allows you to securely sync command history across all your devices with end-to-end encryption.", + "install_methods": [ + { + "type": "default", + "script": "ct/atuin.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 8, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": "atuin", + "password": "atuin" + }, + "notes": [ + { + "text": "PostgreSQL database is configured with username: atuin, password: atuin. Change these for production use.", + "type": "warning" + }, + { + "text": "The server listens on port 8888 by default and has open registration enabled.", + "type": "info" + }, + { + "text": "To connect clients: atuin settings update sync_address http://:8888", + "type": "info" + }, + { + "text": "Users can register with: atuin register --username --password ", + "type": "info" + }, + { + "text": "Server configuration file is located at: /etc/atuin/server.toml", + "type": "info" + }, + { + "text": "For production use, consider setting up TLS by adding the [tls] section to the config file.", + "type": "warning" + }, + { + "text": "Restart the server after config changes with: systemctl restart atuin-server", + "type": "info" + }, + { + "text": "For client usage instructions, visit: https://docs.atuin.sh/guide/basic-usage/", + "type": "info" + }, + { + "text": "View all server logs with: journalctl -u atuin-server", + "type": "info" + }, + { + "text": "Change PostgreSQL credentials with: sudo -u postgres psql -c \"ALTER USER atuin WITH PASSWORD 'new_password';\"", + "type": "info" + } + ] +} diff --git a/install/atuin-install.sh b/install/atuin-install.sh new file mode 100644 index 00000000000..e1164b21e89 --- /dev/null +++ b/install/atuin-install.sh @@ -0,0 +1,176 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: j4v3 (j4v3) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/atuinsh/atuin + +# Import Functions und Setup +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +# Installing Dependencies +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + pkg-config \ + libssl-dev \ + protobuf-compiler \ + postgresql \ + postgresql-contrib + +# Configure PostgreSQL +msg_info "Configuring PostgreSQL" +# Start PostgreSQL service +$STD systemctl start postgresql +$STD systemctl enable postgresql + +# Create a database and user for Atuin +$STD sudo -u postgres psql -c "CREATE USER atuin WITH PASSWORD 'atuin';" +$STD sudo -u postgres psql -c "CREATE DATABASE atuin OWNER atuin;" +$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE atuin TO atuin;" + +# Allow local connections (no remote PostgreSQL access needed) +$STD sed -i "s/#listen_addresses = 'localhost'/listen_addresses = 'localhost'/g" /etc/postgresql/*/main/postgresql.conf +$STD systemctl restart postgresql +msg_ok "Configured PostgreSQL" + +# Install Atuin using the official setup script +msg_info "Installing Atuin" +$STD curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh + +# Get the installed version +ATUIN_VERSION=$(~/.atuin/bin/atuin --version | awk '{print $2}') +msg_ok "Installed Atuin v${ATUIN_VERSION}" + +# Create a symlink in /usr/local/bin for easy access +msg_info "Creating symlink for global access" +$STD ln -sf ~/.atuin/bin/atuin /usr/local/bin/atuin +msg_ok "Created symlink" + +# Setup Atuin Server +msg_info "Setting up Atuin Server" +mkdir -p /etc/atuin/ + +# Create server configuration +cat </etc/atuin/server.toml +# Atuin server configuration +host = "0.0.0.0" +port = 8888 +open_registration = true +db_uri = "postgres://atuin:atuin@localhost/atuin" +EOF + +# Create systemd service for Atuin server +cat </etc/systemd/system/atuin-server.service +[Unit] +Description=Atuin sync server +After=network.target postgresql.service + +[Service] +Type=simple +ExecStart=/usr/local/bin/atuin server start --config /etc/atuin/server.toml +Restart=always +User=root + +[Install] +WantedBy=multi-user.target +EOF + +# Enable and start the Atuin server service +$STD systemctl enable atuin-server +$STD systemctl start atuin-server +msg_ok "Setup Atuin Server" + +# Enable shell integration for local usage +msg_info "Setting up shell integration" + +# For ZSH +if [ -f /bin/zsh ] || [ -f /usr/bin/zsh ]; then + $STD echo 'eval "$(~/.atuin/bin/atuin init zsh)"' >>/etc/zsh/zshrc +fi + +# For Bash +if [ -f /bin/bash ] || [ -f /usr/bin/bash ]; then + # Install bash-preexec for bash integration + $STD curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o /etc/bash-preexec.sh + $STD echo '[[ -f /etc/bash-preexec.sh ]] && source /etc/bash-preexec.sh' >>/etc/bash.bashrc + $STD echo 'eval "$(~/.atuin/bin/atuin init bash)"' >>/etc/bash.bashrc +fi + +msg_ok "Setup shell integration" + +# Create server info file +cat <~/atuin-server-info.txt +Atuin Server Information +======================== + +Server Version: v${ATUIN_VERSION} +Server URL: http://$(hostname -I | awk '{print $1}'):8888 + +DATABASE CONFIGURATION: +---------------------- +PostgreSQL Database: atuin +PostgreSQL User: atuin +PostgreSQL Password: atuin + +SERVER CONFIGURATION: +------------------- +Config Location: /etc/atuin/server.toml +Current Settings: +- host = 0.0.0.0 (listens on all interfaces) +- port = 8888 +- open_registration = true (new users can register) +- db_uri = postgres://atuin:atuin@localhost/atuin + +You can modify these settings in /etc/atuin/server.toml and restart the server: +systemctl restart atuin-server + +CONNECTING CLIENTS: +----------------- +On client machines, install Atuin and then run: + +1. Configure client to use your server: + atuin settings update sync_address http://$(hostname -I | awk '{print $1}'):8888 + +2. Register a new account: + atuin register --username --password + +3. Or login with existing account: + atuin login --username --password + +4. Start syncing: + atuin sync + +SECURITY CONSIDERATIONS: +---------------------- +- The server has open registration enabled by default +- To disable open registration, set 'open_registration = false' in the config +- Consider setting up TLS for secure connections (see documentation) +- For production environments, consider stronger PostgreSQL credentials + +ENABLING TLS: +----------- +To enable TLS, modify /etc/atuin/server.toml to include: + +[tls] +enable = true +cert_path = "/path/to/fullchain.pem" +pkey_path = "/path/to/privkey.pem" + +For more information, visit: https://docs.atuin.sh/self-hosting/server-setup/ +EOF + +motd_ssh +customize + +# Cleanup +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"