Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine Linux doesn't work #383

Open
FireMasterK opened this issue Feb 16, 2023 · 5 comments
Open

Alpine Linux doesn't work #383

FireMasterK opened this issue Feb 16, 2023 · 5 comments

Comments

@FireMasterK
Copy link

Describe the bug
The script doesn't run properly on Alpine Linux.

To Reproduce
Steps to reproduce the behavior:

  1. Get Alpine Linux
  2. curl https://raw.githubusercontent.com/complexorganizations/wireguard-manager/main/wireguard-manager.sh --create-dirs -o /usr/local/bin/wireguard-manager.sh
  3. chmod +x /usr/local/bin/wireguard-manager.sh
  4. Install bash since script doesn't work with ash.
  5. wireguard-manager.sh
  6. The cut command fails, and the script fails due to Alpine Linux not using systemd.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Additional context
Add any other context about the problem here.

@Prajwal-Koirala
Copy link
Member

elif [ "${CURRENT_DISTRO}" == "alpine" ]; then
apk update
apk add curl coreutils jq iproute2 lsof cronie gawk procps grep qrencode sed zip unzip openssl nftables ifupdown e2fsprogs gnupg systemd

Here's a breakdown of the issues and potential approaches for compatibility with Alpine Linux:

1. 'cut' command failure:

  • Potential causes:
    • Alpine Linux might use a different version of 'cut' with varying syntax or options.
    • The script might rely on specific features not present in Alpine's 'cut'.
  • Solutions:
    • Check 'cut' version and syntax: Compare the 'cut' version on Alpine with the one used in development. Adjust syntax as needed.
    • Consider alternative commands: If necessary, explore alternative tools for text manipulation that are compatible with Alpine.

2. Systemd dependency:

  • Problem: The script assumes systemd, which Alpine doesn't use.
  • Solutions:
    • Adapt to OpenRC: Modify script logic to work with OpenRC, Alpine's init system.
    • Explore alternative service management: If appropriate, consider using supervisord or other service management tools compatible with Alpine.

Additional considerations:

  • Bash dependency: If the script requires Bash-specific features, ensure Bash is installed and used correctly on Alpine.
  • Alpine-specific adjustments: Be mindful of Alpine's package management and file system structure, making necessary adjustments.

Recommendations:

  • Engage with the script's maintainers: Notify them of the compatibility issues and potential solutions.
  • Contribute to compatibility: If possible, provide patches or workarounds to make the script Alpine-friendly.
  • Explore alternative tools: Consider other WireGuard management tools that have native Alpine support.

I'm ready to assist further if you have more specific questions or require guidance on implementing these solutions.

@ninchuka
Copy link

alpine:~# bash /usr/local/bin/wireguard-manager.sh
cut: unrecognized option: delimiter=.
BusyBox v1.36.1 (2023-11-07 18:53:09 UTC) multi-call binary.

Usage: cut [OPTIONS] [FILE]...

Print selected fields from FILEs to stdout

        -b LIST Output only bytes from LIST
        -c LIST Output only characters from LIST
        -d SEP  Field delimiter for input (default -f TAB, -F run of whitespace)
        -O SEP  Field delimeter for output (default = -d for -f, one space for -F)
        -D      Don't sort/collate sections or match -fF lines without delimeter
        -f LIST Print only these fields (-d is single char)
        -s      Output only lines containing delimiter
        -n      Ignored
fetch http://alpine.mirror.wearetriple.com/v3.19/main/x86_64/APKINDEX.tar.gz
fetch http://alpine.mirror.wearetriple.com/v3.19/community/x86_64/APKINDEX.tar.gz
v3.19.0-327-g6edd0d6d61c [http://alpine.mirror.wearetriple.com/v3.19/main]
v3.19.0-326-gc0d01ae6d7b [http://alpine.mirror.wearetriple.com/v3.19/community]
OK: 22980 distinct packages available
ERROR: unable to select packages:
  ifupdown (no such package):
    required by: world[ifupdown]
  qrencode (no such package):
    required by: world[qrencode]
  systemd (no such package):
    required by: world[systemd]
/usr/local/bin/wireguard-manager.sh: line 117: systemd-detect-virt: command not found
Error: the  virtualization is currently not supported. Please stay tuned for future updates.

with alpine 3.19, it would be nice to actually test if it works on alpine before putting in alpine as supported since it seems like it wasnt checked

@Prajwal-Koirala
Copy link
Member

https://gist.github.com/Prajwal-Koirala/6055d0e32e02f72d0bbec913d2d509f0

To pull the Alpine Linux image using Docker and run a container with it, you need to have Docker installed on your system. Assuming you have Docker installed, you can follow these steps:

1. **Pull the Alpine Linux Image**: First, you will pull the latest Alpine Linux image from Docker Hub. Open your terminal or command prompt and run the following command:

   ```bash
   docker pull alpine

This command downloads the Alpine image to your local machine.

  1. Run a Container Using the Alpine Image: After pulling the image, you can run a container based on Alpine Linux. Execute the following command:

    docker run -it alpine /bin/sh

    This command will create a new container from the Alpine image and start a shell session inside it. The -it option is used to run the container in interactive mode with a tty so that you can interact with the shell.

Once you run these commands, you will be inside the Alpine Linux environment in your container. You can then proceed to install packages or run commands within the Alpine Linux environment as needed. Remember, when you exit the shell session, the container will stop, but it will not be deleted. You can restart the same container or create a new one as required.

@Prajwal-Koirala
Copy link
Member

Prajwal-Koirala commented Jan 25, 2024

# Use a more recent version of Alpine
FROM alpine:latest

# Update package list and install bash, git, Python, and pip
RUN apk update && apk add --no-cache \
      bash \
      git \
      python3 \
      py3-pip

# Clone the systemd repository
RUN cd /tmp && git clone https://github.com/systemd/systemd

# Set unicode in rc.conf
RUN echo "unicode=\"YES\"" >> /etc/rc.conf

# Install build dependencies
RUN apk add --no-cache --virtual .build_deps \
        autoconf \
        file \
        g++ \
        gcc \
        libc-dev \
        make \
        pkgconf \
        ninja \
        util-linux \
        pciutils \
        usbutils \
        coreutils \
        binutils \
        findutils \
        grep \
        build-base \
        gcc \
        abuild \
        binutils-doc \
        gcc-doc \
        gperf \
        libcap \
        libcap-dev \
        valgrind-dev

# Create a virtual environment and install meson
RUN python3 -m venv /venv && \
    source /venv/bin/activate && \
    pip3 install meson

# Compile systemd (this might not work as expected)
RUN source /venv/bin/activate && \
    cd /tmp/systemd && \
    meson build && \
    ninja -C build

# Cleanup: Remove build dependencies and deactivate virtual environment
RUN apk del .build_deps && \
    deactivate

@Prajwal-Koirala
Copy link
Member

/tmp/systemd # bash /usr/local/bin/wireguard-manager.sh
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/aarch64/APKINDEX.tar.gz
v3.19.0-341-gfaf9f17e39b [https://dl-cdn.alpinelinux.org/alpine/v3.19/main]
v3.19.0-346-g8109425de2e [https://dl-cdn.alpinelinux.org/alpine/v3.19/community]
OK: 22841 distinct packages available
OK: 127 MiB in 115 packages
/usr/local/bin/wireguard-manager.sh: line 118: systemd-detect-virt: command not found
Error: the  virtualization is currently not supported. Please stay tuned for future updates.
/tmp/systemd # systemd-detect-virt
/bin/sh: systemd-detect-virt: not found
/tmp/systemd # apk add systemd
ERROR: unable to select packages:
  systemd (no such package):
    required by: world[systemd]
/tmp/systemd # 
/tmp/systemd # apk add systemd
ERROR: unable to select packages:
  systemd (no such package):
    required by: world[systemd]
/tmp/systemd # 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants