Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8fd313d2 authored by Akhil's avatar Akhil 🙂
Browse files

Merge branch '2.0' into performance-improvements

parents 753b6739 827cf059
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -27,15 +27,41 @@ RUN a2enmod rewrite
COPY conf/perf.conf /etc/apache2/conf-available/perf.conf
RUN a2enconf perf

# install the PHP extensions we need
RUN apt-get update \
        && apt-get install nano \
        && buildDeps=" \
                zlib1g-dev \
        " \
        && apt-get install -y git $buildDeps --no-install-recommends \
        && rm -r /var/lib/apt/lists/* \
        \
        && docker-php-ext-install zip \
        \
        && pecl install apcu \
        && docker-php-ext-enable apcu \
        \
        && docker-php-source delete \
        && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps 
# set recommended settings for APCu
# see http://php.net/manual/en/apcu.configuration.php
RUN { \
    echo 'apc.ttl=7200'; \
  } > /usr/local/etc/php/conf.d/opcache-recommended.ini

# install latest version of composer
# Install composer from the official image
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Run composer install to install the dependencies
RUN composer install --optimize-autoloader --no-interaction --no-progress
ADD https://getcomposer.org/composer.phar /usr/local/bin/composer
RUN chmod 0755 /usr/local/bin/composer

# add all the project files
COPY . $HTML_DIR

# enable indexing for Apache
RUN sed -i "1s;^;Options +Indexes\n\n;" .htaccess

# install dependencies
RUN composer install --no-plugins --no-scripts

# fix permissions
RUN chmod -R 0775 /var/www/html \
    && chown -R www-data:www-data /var/www/html
+1 −1
Original line number Diff line number Diff line
The MIT License (MIT)

Copyright (c) 2016 Julian Xhokaxhiu
Copyright (c) 2020 Julian Xhokaxhiu

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
+10 −25
Original line number Diff line number Diff line
@@ -14,29 +14,6 @@ Got a question? Not sure where it should be made? See [CONTRIBUTING](CONTRIBUTIN

## How to use

### Test

```
$ sudo docker build -t e/lineageota . \
    && sudo docker run \
        -d \
        -p 80:80 \
        --rm \
        -v "${PWD}/builds/full:/var/www/html/builds/full" \
        --name lineageota \
        e/lineageota
```

Access to API via http://localhost/api/v1/\<device\>/\<channel\>

Get logs with

```
$ sudo docker exec -ti lineageota tail -f LineageOTA.log
```

You can also use this server with a device connected to the same network, specifying the correct IP (see below).

### Composer

```shell
@@ -44,7 +21,7 @@ $ cd /var/www/html # Default Apache WWW directory, feel free to choose your own
$ composer create-project julianxhokaxhiu/lineage-ota LineageOTA
```

then finally visit http://localhost/LineageOTA to see the REST Server up and running.
then finally visit http://localhost/LineageOTA to see the REST Server up and running. Please note that this is only for a quick test, when you plan to use that type of setup for production (your users), make sure to also provide HTTPS support.

> If you get anything else then a list of files, contained inside the `builds` directory, this means something is wrong in your environment. Double check it, before creating an issue report here.

@@ -124,10 +101,12 @@ In order to integrate this in your LineageOS based ROM, you need to add the [`li

```properties
# ...
lineage.updater.uri=http://my.ota.uri/api/v1/{device}/{type}/{incr}
lineage.updater.uri=https://my.ota.uri/api/v1/{device}/{type}/{incr}
# ...
```

Make always sure to provide a HTTPS based uri, otherwise the updater will reject to connect with your server! This is caused by the security policies newer versions of Android (at least 10+) include, as any app wanting to use non-secured connections must explicitly enable this during the compilation. The LineageOS Updater does not support that.

> Since https://review.lineageos.org/#/c/191274/ is merged, the property `cm.updater.uri` is renamed to `lineage.updater.uri`. Make sure to update your entry.

> As of [5252d60](https://github.com/LineageOS/android_packages_apps_Updater/commit/5252d606716c3f8d81617babc1293c122359a94d):  
@@ -147,6 +126,12 @@ In order to integrate this in your [CyanogenMod](https://github.com/lineageos/an

## Changelog

### v2.9.0
- Add PHP 7.4 compatibility: Prevent null array access on `isValid()` ( thanks to @McNutnut )
- Update RegEx pattern to match more roms than just CM/LineageOS ( thanks to @toolstack )
- Use Forwarded HTTP Extension to determine protocol and host ( thanks to @TpmKranz )
- Add detection of HTTP_X_FORWARDED_* headers ( thanks to @ionphractal )

### v2.8.0

- Use md5sum files if available ( thanks to @jplitza )
+3 −3
Original line number Diff line number Diff line
{
  "name": "julianxhokaxhiu/lineage-ota",
  "description": "A simple OTA REST Server for LineageOS OTA Updater System Application",
  "version": "2.8.1",
  "version": "2.9.0",
  "type": "project",
  "keywords": [
    "android",
@@ -26,7 +26,7 @@
      "type":"package",
      "package": {
        "name": "julianxhokaxhiu/dotnotation",
        "version": "dev-master",
        "version": "master",
        "source": {
          "url": "https://gist.github.com/a6098de64195f604f56a.git",
          "type": "git",
@@ -42,7 +42,7 @@
    "mikecao/flight": "1.*",
    "julianxhokaxhiu/dotnotation": "dev-master",
    "ext-zip": "*",
    "monolog/monolog": "1.23.*"
    "monolog/monolog": "2.2.*"
  },
  "autoload": {
    "psr-4": {
+27 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
    /*
        The MIT License (MIT)

        Copyright (c) 2016 Julian Xhokaxhiu
        Copyright (c) 2020 Julian Xhokaxhiu

        Permission is hereby granted, free of charge, to any person obtaining a copy of
        this software and associated documentation files (the "Software"), to deal in
@@ -28,8 +28,33 @@
    use Monolog\Logger;
    use Monolog\Handler\StreamHandler;

    $protocol = 'https://';
    if ( isset($_SERVER['HTTP_FORWARDED']) ) {
      $fwd_ar = explode(';', $_SERVER['HTTP_FORWARDED']);
      for ( $i = 0; $i < count($fwd_ar); $i++ ) {
        $kv = explode('=', $fwd_ar[$i]);
        if ( count($kv) > 1 ) {
          $forwarded[strtoupper($kv[0])] = $kv[1];
        }
      }
      if ( array_key_exists('HOST', $forwarded) ) {
        $_SERVER['HTTP_HOST'] = $forwarded['HOST'];
      }
      if ( array_key_exists('PROTO', $forwarded) && strtoupper($forwarded['PROTO']) === 'HTTPS') {
        $_SERVER['HTTPS'] = 'on';
      }
    } else {
      if ( isset($_SERVER['HTTP_X_FORWARDED_HOST']) ) {
        $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
      }
      if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtoupper($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'HTTPS' ) {
        $_SERVER['HTTPS'] = 'on';
      }
    }

    if( isset($_SERVER['HTTPS']) )
        $protocol = 'https://';
    else
        $protocol = 'http://';
    $logger = new Logger('main');
    $logger->pushHandler(new StreamHandler('LineageOTA.log', Logger::WARNING));

Loading